plotters
plotters copied to clipboard
Can I add text in the graph?
I tried add a multi lines text in the graph, but the text can only shown in one line, like this:
pub fn plot_test() -> evcxr::SVGWrapper { evcxr_figure((500, 500), |root| { root.fill(&WHITE)?; let te = Text::new(format!("a \n b"), (40, 20), ("sans-serif", 15.0).into_font()); root.draw(&te)?; Ok(()) }) }
As can be seen in the above figure, the "\n" between a and b does not work.
If you know exactly where you want to put the text, you could draw the chart to a buffer, drop the chart, then pass the buffer directly into skia_safe and draw the text from there
There is a MultiLineText, which can show a multiline string. I mean you need to call MultiLineText::push_line()
multiple times to push your lines into it one by one.