Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Grid example #84

Open
krestomantsi opened this issue Aug 8, 2023 · 2 comments
Open

Grid example #84

krestomantsi opened this issue Aug 8, 2023 · 2 comments

Comments

@krestomantsi
Copy link

Please do make a simple example on how to use set_x_grid/set_y_grid cause either the doc is misleading or this is a bug. thank you.

  let mut fg = Figure::new();
  let x02 = Array::linspace(-1.0, 1.0, 100)
      .insert_axis(Axis(1))
      .mapv(|xi| xi as f32);
  let y02 = mlp.forward(&x02);
  fg.axes2d()
      .points(&x0, &y0, &[Caption("data"), Color("blue")]);
  //grid??
  fg.axes2d().set_x_grid(true).set_y_grid(true);

  fg.save_to_png("plot.png", 800, 600)
      .expect("Unable to save plot");
  println!("Plot saved");
@SiegeLord
Copy link
Owner

You want to do:

let ax = fg.axes2d();
ax.points(&x0, &y0, &[Caption("data"), Color("blue")]);
ax.set_x_grid(true).set_y_grid(true);

Your snippet is creating a second axis, which I guess gets overlapped by the first axis? That could be a bug in principle.

@krestomantsi
Copy link
Author

Thank you for everything ! Awesome package as well!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants