plotters-rs / plotters

A rust drawing library for high quality data plotting for both WASM and native, statically and realtimely 🦀 📈🚀
https://plotters-rs.github.io/home/
MIT License
3.89k stars 281 forks source link

[BUG] LineSeries and draw_series go out of the image scope if stroke_width > 1 #549

Open fitz35 opened 9 months ago

fitz35 commented 9 months ago

Describe the bug Describe what is expected, what you actually get. It would be nice to have screenshot or result image uploaded
When using draw_series and LineSeries with BitMapBackend on highly variable data, augmenting the stroke width made the line to go out of the image. The following graph is plotted with a stroke width of 2 :

line_performance_comparaison_language_without_outliers

The same graphic with a stroke width of 1 : line_performance_comparaison_language_without_outliers

NOTE : The change of color is because I use a HashMap to plot the serie. To Reproduce Some minimal reproduce code is highly recommended

I can export data which are "highly variable", but I'm not sure how to give access to it. Here is the code I use :

// stroke width 1
chart
                .draw_series(
                    LineSeries::new(
                        data_for_legend.iter().map(|(x, y)| (*x, *y)),
                        color.filled().stroke_width(1)
                    )
                )?;

// stroke width 2
chart
                .draw_series(
                    LineSeries::new(
                        data_for_legend.iter().map(|(x, y)| (*x, *y)),
                        color.filled().stroke_width(2)
                    )
                )?;

Version Information Please give us what version you are using. If you are pulling Plotters directly from git repo, please mention this as well The version I use is the 0.3.3.