pub struct Plot {
pub xs: Matrix,
pub ys: Matrix,
pub line_desc: Vec<LineDesc>,
pub axis_desc: AxisDesc,
pub desc: Desc,
}
Fields§
§xs: Matrix
§ys: Matrix
§line_desc: Vec<LineDesc>
§axis_desc: AxisDesc
§desc: Desc
Implementations§
Source§impl Plot
impl Plot
Sourcepub fn set_desc(&mut self, desc: Desc)
pub fn set_desc(&mut self, desc: Desc)
Examples found in repository?
More examples
examples/collatz.rs (lines 6-10)
3fn main() {
4 let mut plot = Plot::default();
5 plot.set_title("Collatz Conjecture");
6 plot.set_desc(Desc {
7 min_steps_x: 10.,
8 spacing_x: 47.,
9 ..Default::default()
10 });
11
12 for input in 1000..=1001 {
13 let mut single_graph = collatz(input as f64).as_plot();
14 single_graph.set_color(0., 1. * (input == 1000) as i32 as f32, 1.);
15 plot.add(single_graph);
16 }
17 plot.show();
18}
Sourcepub fn set_color(&mut self, r: f32, g: f32, b: f32)
pub fn set_color(&mut self, r: f32, g: f32, b: f32)
Set graph color
§Example
use graplot::Plot;
let mut plot = Plot::new([1., 2., 3.]);
plot.set_color(0., 0.78, 1.);
plot.show();
Examples found in repository?
examples/collatz.rs (line 14)
3fn main() {
4 let mut plot = Plot::default();
5 plot.set_title("Collatz Conjecture");
6 plot.set_desc(Desc {
7 min_steps_x: 10.,
8 spacing_x: 47.,
9 ..Default::default()
10 });
11
12 for input in 1000..=1001 {
13 let mut single_graph = collatz(input as f64).as_plot();
14 single_graph.set_color(0., 1. * (input == 1000) as i32 as f32, 1.);
15 plot.add(single_graph);
16 }
17 plot.show();
18}
Sourcepub fn color(&mut self, idx: usize, color: Color)
pub fn color(&mut self, idx: usize, color: Color)
Colors the graph at the given index with the color.
§Example
use graplot::{Plot, BLUE};
let mut plot = Plot::new([1., 2., 3.,]);
plot.add([2., 3., 4.,]);
plot.color(1, BLUE);
plot.show();
Sourcepub fn add<A: PlotArg>(&mut self, args: A)
pub fn add<A: PlotArg>(&mut self, args: A)
adds a new graph / plot to the original plot.
Examples found in repository?
examples/multiple_plots.rs (line 12)
3fn main() {
4 let xs = [1., 2., 3.];
5 let ys = [1.7, 3., 1.9];
6
7 let ys1 = [1.4, 1.6, 1.5];
8
9 let ys2 = [0.9, 1.2, 1.7, 1.9, 2.];
10
11 let mut plot = Plot::new((xs, ys));
12 plot.add((xs, ys1, "c-o"));
13 plot.add((ys2, "r-"));
14 plot.show();
15}
More examples
examples/collatz.rs (line 15)
3fn main() {
4 let mut plot = Plot::default();
5 plot.set_title("Collatz Conjecture");
6 plot.set_desc(Desc {
7 min_steps_x: 10.,
8 spacing_x: 47.,
9 ..Default::default()
10 });
11
12 for input in 1000..=1001 {
13 let mut single_graph = collatz(input as f64).as_plot();
14 single_graph.set_color(0., 1. * (input == 1000) as i32 as f32, 1.);
15 plot.add(single_graph);
16 }
17 plot.show();
18}
Sourcepub fn set_title(&mut self, title: &str)
pub fn set_title(&mut self, title: &str)
Examples found in repository?
More examples
examples/collatz.rs (line 5)
3fn main() {
4 let mut plot = Plot::default();
5 plot.set_title("Collatz Conjecture");
6 plot.set_desc(Desc {
7 min_steps_x: 10.,
8 spacing_x: 47.,
9 ..Default::default()
10 });
11
12 for input in 1000..=1001 {
13 let mut single_graph = collatz(input as f64).as_plot();
14 single_graph.set_color(0., 1. * (input == 1000) as i32 as f32, 1.);
15 plot.add(single_graph);
16 }
17 plot.show();
18}
Sourcepub fn set_xlabel(&mut self, label: &str)
pub fn set_xlabel(&mut self, label: &str)
Sourcepub fn set_ylabel(&mut self, label: &str)
pub fn set_ylabel(&mut self, label: &str)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Plot
impl RefUnwindSafe for Plot
impl Send for Plot
impl Sync for Plot
impl Unpin for Plot
impl UnwindSafe for Plot
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more