Skip to content

Plotting f64::NAN drops nearby points and disconnects line #131

@CramBL

Description

@CramBL

Describe the bug

Adding NaN values to a PlotPoints disconnects the line plot, and drops nearby points (not sure of the exact behavior of which points are dropped).

I didn't find any description of what the expected behaviour is when you attempt to plot NaN.

To Reproduce
Steps to reproduce the behavior:

  1. Clone the minimal example: https://github.com/CramBL/egui-nan-example
  2. cargo run

Or create an eframe project and copy this into eframe::update

egui::CentralPanel::default().show(ctx, |ui| {
    let values = [1.0, 2.0, 3.0, f64::NAN, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0];

    let points: PlotPoints = values
        .iter()
        .enumerate()
        .map(|(i, &y)| [i as f64, y])
        .collect();

    Plot::new("line_plot").show(ui, |plot_ui| {
        plot_ui.line(Line::new("series", points));
    });
});

Expected behavior

Not sure, maybe to drop the NaN point and still connect the other lines?

Screenshots

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions