Skip to content

[BUG] with_key_points with floats causes configure_mesh to not compile #739

@pmielle

Description

@pmielle

Describe the bug
I was trying to use with_key_points to manually set the ticks of my x-axis, but I couldn't get it to compile when using floats. As far as I know, it works great when the axis uses integers, but when using floats it causes configure_mesh to not compile (cf below).
Looks like someone else ran into this issue here and also someone on reddit.
Would love to help but not sure I am good enough at rust

To Reproduce

let drawing_area = BitMapBackend::new("./test.png", (640, 480)).into_drawing_area();
let mut plot = ChartBuilder::on(&drawing_area)
    .build_cartesian_2d((0f32..3.5f32).with_key_points(vec![1f32, 2f32]), 0..10)
    .unwrap();
plot.configure_mesh().draw().unwrap(); // <-- does not compile

the compilor error is:

  1. the method configure_mesh exists for struct ChartContext<'_, BitMapBackend<'_>, Cartesian2d<..., _>> , but its trait bounds were not satisfied
    the following trait bounds were not satisfied:
    <WithKeyPoints<RangedCoordf32> as Ranged>::FormatOption = DefaultFormatting
    which is required by WithKeyPoints<RangedCoordf32>: ValueFormatter<f32>

Version Information
plotters 0.3.7

(thanks for the work on plotters!)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions