Y labels are not aligned
wangjiawen2013 opened this issue · 1 comments
wangjiawen2013 commented
Hi,
When plotting both the left and right y-axis, the labels on the left y-axis was not aligned:
evcxr_figure((640, 480), |root| {
let x_axis = (-3.4f32..3.4).step(0.01);
root.fill(&WHITE)?;
let mut chart = ChartBuilder::on(&root).margin(1)
.set_all_label_area_size(50)
.build_cartesian_2d(-3.4f32..3.4, -1.2f32..1.2f32)?;
chart.configure_mesh().x_labels(20).y_labels(10).disable_mesh()
.x_desc("X")
.y_desc("Y")
.label_style(("sans-serif", 20, &BLACK))
.x_label_formatter(&|v| format!("{:.1}", v))
.y_label_formatter(&|v| format!("{:.1}", v))
.draw()?;
chart.draw_series(LineSeries::new(x_axis.values().map(|x| (x, x.sin())), &RED))?
.label("sin")
.legend(|(x, y)| PathElement::new(vec![(x,y), (x+20,y)], &RED));
chart.draw_series(LineSeries::new(x_axis.values().map(|x| (x, x.cos())), &BLUE))?
.label("cos")
.legend(|(x, y)| PathElement::new(vec![(x,y), (x+20,y)], &BLUE));
chart.configure_series_labels()
.margin(10)
.position(SeriesLabelPosition::UpperLeft)
.border_style(&BLACK)
.label_font(("Calibri", 20))
.draw()?;
Ok(())
}).style("width:60%")
here is the result, it seems that the alignment of right y-axis are affected by the negative sign:
wangjiawen2013 commented