MCPcopy Create free account
hub / github.com/cpmech/plotpy / draw

Method draw

src/fill_between.rs:73–90  ·  view source on GitHub ↗

Draws the filled area between two curves (or between a curve and the x-axis) # Input `x` -- shared x-axis values `y1` -- y values of the first curve (variable name: `y1`) `y2` -- optional y values of the second curve (variable name: `y2`). If `None`, fills the area between `y1` and the x-axis (`y = 0`). # Note For two-color filling (above/below a threshold), use [`set_where`](Self::set_where)

(&mut self, x: &'a T, y1: &'a T, y2: Option<&'a T>)

Source from the content-addressed store, hash-verified

71 /// For two-color filling (above/below a threshold), use [`set_where`](Self::set_where)
72 /// with a condition referencing `y1` and `y2`.
73 pub fn draw<'a, T, U>(&mut self, x: &'a T, y1: &'a T, y2: Option<&'a T>)
74 where
75 T: AsVector<'a, U>,
76 U: 'a + std::fmt::Display + Num,
77 {
78 let opt = self.options();
79 vector_to_array(&mut self.buffer, "x", x);
80 vector_to_array(&mut self.buffer, "y1", y1);
81 match y2 {
82 Some(y2) => {
83 vector_to_array(&mut self.buffer, "y2", y2);
84 write!(&mut self.buffer, "plt.fill_between(x,y1,y2{})\n", &opt).unwrap();
85 }
86 None => {
87 write!(&mut self.buffer, "plt.fill_between(x,y1{})\n", &opt).unwrap();
88 }
89 }
90 }
91
92 /// Sets the condition that selects which region to fill
93 ///

Callers

nothing calls this directly

Calls 2

vector_to_arrayFunction · 0.85
optionsMethod · 0.45

Tested by

no test coverage detected