Guest User

Untitled

a guest
May 22nd, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. extern crate dataplotlib;
  2. use dataplotlib::util::{linspace, zip2};
  3. use dataplotlib::plotbuilder::PlotBuilder2D;
  4. use dataplotlib::plotter::Plotter;
  5.  
  6. fn main() {
  7. let x = linspace(0, 10, 100);
  8.  
  9. let y_sin = x.iter().map(|x| x.sin()).collect();
  10. let xy_sin = zip2(&x, &y_sin);
  11.  
  12. let xy_lin = zip2(&x, &x);
  13.  
  14. // Creates a new plot builder
  15. let mut pb = PlotBuilder2D::new();
  16.  
  17. // Adds the sin plot and the linear plot with custom colors
  18. pb.add_color_xy(xy_sin, [1.0, 0.0, 0.0, 1.0]);
  19. pb.add_color_xy(xy_lin, [0.0, 0.0, 1.0, 1.0]);
  20.  
  21. let mut plt = Plotter::new();
  22. plt.plot2d(pb);
  23. plt.join();
  24. }
Add Comment
Please, Sign In to add comment