-
Notifications
You must be signed in to change notification settings - Fork 47
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
String labels for xtic #35
Comments
You can do this: let mut fg = Figure::new();
c.set_term(&mut fg);
fg.axes2d()
.boxes(&[1., 2., 3.], &[1., 2., 3.], &[Color("gray"), BorderColor("black")])
.set_x_ticks_custom(
vec![
Major(1. as f32, Fix("A".into())),
Major(2. as f32, Fix("B".into())),
Major(3. as f32, Fix("C".into()))
],
&[],
&[],
)
.set_y_range(Fix(0.0), Auto);
fg.show(); to get: |
Or, if your have an array of labels: let mut fg = Figure::new();
c.set_term(&mut fg);
let x = [1., 2., 3.];
let y = [1., 2., 3.];
let l = ["A", "B", "C"];
fg.axes2d()
.boxes(&x, &y, &[Color("gray"), BorderColor("black")])
.set_x_ticks_custom(
x.iter().zip(&l).map(|(&x, &l)| Major(x as f32, Fix(l.into()))),
&[],
&[],
)
.set_y_range(Fix(0.0), Auto);
fg.show(); |
Thank you! this helped a lot 👍 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I was creating a bar chart using this library but found that it would not allow for strings to be attached to xtics. If this could be added it would be immensely useful for creating bar charts.
The text was updated successfully, but these errors were encountered: