graplot
'graplot' is an experimental plotting library written in Rust that is based on macroquad (internally litequad). It creates a window displaying the graphs.
Installation
Add 'graplot' as a dependency:
[]
= "0.1.22"
Examples
use Plot;
let plot = new;
plot.show;
3D line plot:
use Plot3D;
let xs = ;
let ys = ;
let zs = ;
// move with: W, A, S, D
let plot = new;
plot.show;
Multiple graphs:
use Plot;
let xs = ;
let ys = ;
let ys1 = ;
let ys2 = ;
let mut plot = new;
plot.add;
plot.add;
plot.show;
Label the x and y axis and set a title:
use ;
let mut plot = new;
plot.set_title;
plot.set_xlabel;
plot.set_ylabel;
plot.show;
Draw pie charts:
use Pie;
// without labels: let pie = Pie::new([35., 25., 25., 15.]);
let draw = ;
let pie = new;
pie.show;
Sine wave:
use Plot;
let mut xs = ;
let mut add = 0f64;
for idx in 0..1000
let mut ys = ;
for in ys.iter_mut.enumerate
// or alternatively: let plot = Plot::new((|x: f64| x.sin(), x(4.)));
let plot = new;
plot.show;
x³ + x² - 0.08:
use ;
// x(...) ... sets the absolute max value for x
let plot = new;
plot.show;
x² - 0.5:
use Plot;
let plot = new;
plot.show;
Use the Polynomial struct or polynomial() function to create a polynomial function that runs through all given points:
use ;
let poly = new;
let plot = new;
plot.show;
Draw bar graphs:
use Bar;
let mut bar = new;
bar.set_title;
bar.set_xlabel;
bar.show;
Using a line description: (matplotlib)
use Plot;
// c ... cyan color, - ... solid line, o ... ring marker
let plot = new;
plot.show;
Draw graphs with nodes and egdes:
use ;
let mut graph = new;
graph.graph_desc = GraphDesc ;
let a = graph.add_node;
let b = graph.add_node;
let c = graph.add_node;
let d = graph.add_node;
let e = graph.add_node;
graph.add_node;
graph.show;
Custom scaling:
use ;
let mut plot = new;
plot.set_desc;
plot.show;
Spawning multiple windows on linux (currently not working):
let mut plot = new;
plot.set_title;
let h = plot.show_threaded // show_threaded() is currently linux only;
let mut plot = new;
plot.set_title;
plot.show;
h.join.unwrap // you need to close both windows
Changelog
- 0.1.22: added ToF64
- 0.1.22: added graphs (nodes, edges)
- 0.1.19: negative value bars
- 0.1.18: bugfixes
- 0.1.17: basic 3d plotting
- 0.1.16: coloring,
- 0.1.15: easier colored bars
- 0.1.14: ???
- 0.1.13: added pie charts
- 0.1.12: added bar graphs
- 0.1.11: added scatter plots
- 0.1.10: create polynomial functions with a set of points
- 0.1.9: fixed bug
- 0.1.8: set color now uses 3 args, fixed step size
- 0.1.7: Set graph color, custom x & y "line" spacing and step size | "custom scaling"
- 0.1.6: Label x axis, litequad
- 0.1.5: y axis, set title, /mutliple windows on linux/ | yanked
- 0.1.4: Multiple graphs