Skip to content

[BUG] Drawing off by a few px #165

Open
@jangernert

Description

@jangernert

Describe the bug
At least with the CanvasBackend the drawing of the axis seems to be off a little. Some lines of the axis don't quite connect. Some overlap which looks bad with the default opacity of the line.

It seems like the thickness of the line is not taken into consideration when drawing.

canvas

Overlap:

Screenshot from 2020-07-19 15-28-39

Overlap and end of X-Axis a little too short:

Screenshot from 2020-07-19 15-29-05

Axis not quite connecting right at 0:

Screenshot from 2020-07-19 15-28-05

Top of Y-Axis not going all the way to the top

Screenshot from 2020-07-19 15-28-23

To Reproduce

let backend = CanvasBackend::new("canvas").unwrap();
let root = backend.into_drawing_area();

root.fill(&WHITE).unwrap();

let mut chart = ChartBuilder::on(&root)
    .set_left_and_bottom_label_area_size(30)
    .margin(10)
    .build_ranged(0.0..2.0, 0.0..3.0)
    .unwrap();

chart
    .configure_mesh()
    .x_labels(3)
    .y_labels(2)
    .draw()
    .unwrap();

let data = (0..=20)
    .map(|x| x as f64 / 10.0)
    .map(|x| (x, x.powf(2.0) + 1.0));

chart.draw_series(
    AreaSeries::new(
        data.clone(),
        0.0,
        &RED.mix(0.2),
    )
    .border_style(&RED),
).unwrap();

chart.draw_series(
    data
        .map(|(x, y)| Circle::new((x, y), 3, BLUE.filled())),
).unwrap();

root.present().unwrap();

Version Information

plotters = "0.2"

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions