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)
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
fn main() {
let mut plot = Plot::default();
plot.set_title("Collatz Conjecture");
plot.set_desc(Desc {
min_steps_x: 10.,
spacing_x: 47.,
..Default::default()
});
for input in 1000..=1001 {
let mut single_graph = collatz(input as f64).as_plot();
single_graph.set_color(0., 1. * (input == 1000) as i32 as f32, 1.);
plot.add(single_graph);
}
plot.show();
}
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)
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
fn main() {
let mut plot = Plot::default();
plot.set_title("Collatz Conjecture");
plot.set_desc(Desc {
min_steps_x: 10.,
spacing_x: 47.,
..Default::default()
});
for input in 1000..=1001 {
let mut single_graph = collatz(input as f64).as_plot();
single_graph.set_color(0., 1. * (input == 1000) as i32 as f32, 1.);
plot.add(single_graph);
}
plot.show();
}
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)
3 4 5 6 7 8 9 10 11 12 13 14 15
fn main() {
let xs = [1., 2., 3.];
let ys = [1.7, 3., 1.9];
let ys1 = [1.4, 1.6, 1.5];
let ys2 = [0.9, 1.2, 1.7, 1.9, 2.];
let mut plot = Plot::new((xs, ys));
plot.add((xs, ys1, "c-o"));
plot.add((ys2, "r-"));
plot.show();
}
More examples
examples/collatz.rs (line 15)
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
fn main() {
let mut plot = Plot::default();
plot.set_title("Collatz Conjecture");
plot.set_desc(Desc {
min_steps_x: 10.,
spacing_x: 47.,
..Default::default()
});
for input in 1000..=1001 {
let mut single_graph = collatz(input as f64).as_plot();
single_graph.set_color(0., 1. * (input == 1000) as i32 as f32, 1.);
plot.add(single_graph);
}
plot.show();
}
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)
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
fn main() {
let mut plot = Plot::default();
plot.set_title("Collatz Conjecture");
plot.set_desc(Desc {
min_steps_x: 10.,
spacing_x: 47.,
..Default::default()
});
for input in 1000..=1001 {
let mut single_graph = collatz(input as f64).as_plot();
single_graph.set_color(0., 1. * (input == 1000) as i32 as f32, 1.);
plot.add(single_graph);
}
plot.show();
}