You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
I've been playing around with the plotters library and even creating my own utility crate using it, and I was surprised to see that when a point is out of range of the plotting area, it is drawn somewhere close to the edge of the plotting area (the expected behavior would be that it is not drawn at all). I would say that this causes the plot to be "incorrect" and thus qualifies as a "BUG".
To Reproduce
In a jupyter notebook:
1st cell:
:dep plotters = { version = "0.3.7", defualt_features=false, features=["evcxr", "all_series"]}
use plotters::prelude::*;
2nd cell:
let points1 = vec![0.2, 0.4, 0.6, 0.8];
let points2 = vec![0.2, 0.9, 1.6, 2.3];
evcxr_figure((640, 480), |root| {
// The following code will create a chart context
let (up, down) = root.split_vertically(240);
let mut chart = ChartBuilder::on(&up)
.caption("(Incorrect) Should be linear; points do not fit into chart and are forced into it", ("Arial", 20).into_font())
.x_label_area_size(40)
.y_label_area_size(40)
.build_cartesian_2d(0f64..1f64, 0f64..1f64)?;
chart.configure_mesh()
.disable_x_mesh()
.disable_y_mesh()
.draw()?;
chart.draw_series(points1.iter().zip(points2.iter()).map(|(x,y)| Circle::new((*x,*y), 3, RED.filled())));
let mut chart = ChartBuilder::on(&down)
.caption("(Correct) Linear relationship; points fit into chart", ("Arial", 20).into_font())
.x_label_area_size(40)
.y_label_area_size(40)
.build_cartesian_2d(0f64..1f64, 0f64..3f64)?;
chart.configure_mesh()
.disable_x_mesh()
.disable_y_mesh()
.draw()?;
chart.draw_series(points1.iter().zip(points2.iter()).map(|(x,y)| Circle::new((*x,*y), 3, RED.filled())));
Ok(())
}).style("width:60%")
Version Information
plotters version 0.3.7
The text was updated successfully, but these errors were encountered:
@yygrechka,
Could you add a filter?
instead of chart.draw_series(points1.iter().zip(points2.iter()).map(|(x,y)| Circle::new((*x,*y), 3, RED.filled())));
do chart.draw_series(points1.iter().zip(points2.iter()).filter(|(x,y)| **y < 1f64).map(|(x,y)| Circle::new((*x,*y), 3, RED.filled())));
Describe the bug
I've been playing around with the plotters library and even creating my own utility crate using it, and I was surprised to see that when a point is out of range of the plotting area, it is drawn somewhere close to the edge of the plotting area (the expected behavior would be that it is not drawn at all). I would say that this causes the plot to be "incorrect" and thus qualifies as a "BUG".
To Reproduce
In a jupyter notebook:
1st cell:
2nd cell:
Version Information
plotters version 0.3.7
The text was updated successfully, but these errors were encountered: