emilk / egui_plot

2D plotting library in Rust for egui
Apache License 2.0
95 stars 31 forks source link

[egui_plot] linked axes wrong scale/bounds #14

Open jordens opened 1 year ago

jordens commented 1 year ago

Describe the bug

Linked axes are inaccurately linked. Compare the y axis of the top left and right plots in the screenshot.

There are a couple more fragility issues with axes linking but this appears to be a dominant one.

To Reproduce Steps to reproduce the behavior:

  1. https://www.egui.rs/#Demo
  2. Select "Plot" from Egui demos
  3. Select "Linked Axes" tab
  4. Observe incorrect y axis scaling between top left and right plots (range in top left plot is larger)

Expected behavior Correctly scaled and linked axis.

Screenshots image

Desktop (please complete the following information):

Additional context egui 0.23 egui_plot 0.23 (also still occurs in current master as of fd75adb)

bircni commented 3 months ago

Seems like it's not happening in egui 0.28 anymore image

@jordens

jordens commented 3 months ago

It is:

354903699-09371375-4d97-4444-8f73-f829d35728a7~2

bircni commented 3 months ago

@YgorSouza what do you think?

YgorSouza commented 3 months ago

It's still the same as when the issue was opened. I don't think anyone has worked on that. I noticed that this change makes the axes match perfectly:

M demo/src/plot_demo.rs
@@ -652,7 +652,7 @@ impl LinkedAxesDemo {
                 .link_cursor(link_group_id, self.link_cursor_x, self.link_cursor_y)
                 .show(ui, Self::configure_plot);
             Plot::new("right-top")
-                .data_aspect(2.0)
+                .data_aspect(1.9)
                 .width(150.0)
                 .height(250.0)
                 .y_axis_label("y")

But I don't know why. Clearly the linked axes don't deal with aspect ratio differences well, but even if we make both plots the same height and width, we have to set the aspect ratio on the second one to 1.05 instead of 1.0 for them to match. Not sure where that is coming from. Removing the data_aspect from both plots also works, so that's probably the place to look.