emilk / emilk/egui_plot

Plotting `f64::NAN` drops nearby points and disconnects line

Open
#131 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Rust
Stars
468
Forks
108
Avg merge
15m
Merged PRs (30d)
3

Description

**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`
```rust
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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.