Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto bounds breaks link_axis and link_cursor #75

Open
tripokey opened this issue Feb 7, 2025 · 0 comments
Open

Auto bounds breaks link_axis and link_cursor #75

tripokey opened this issue Feb 7, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@tripokey
Copy link

tripokey commented Feb 7, 2025

Describe the bug

While auto bounds is active link_axis and link_cursor does not work if the plot data for the different plots have a different width.

The linking works if the user zoom's in, but when the user double clicks to enable auto bounds the plots are unaligned again.

To Reproduce

Run the following example:

use eframe::egui;
use egui_plot::Line;

fn main() -> eframe::Result {
    let native_options = eframe::NativeOptions::default();

    eframe::run_simple_native("UnalignedPlots", native_options, move |ctx, _frame| {
        egui::CentralPanel::default().show(ctx, |ui| {
            let plot_height = ui.available_height() / 2.0;

            egui_plot::Plot::new("Plot1")
                .height(plot_height)
                .link_axis("plot_axis", [true, false])
                .link_cursor("plot_cursor", [true, false])
                .show(ui, |ui| {
                    ui.line(Line::new(vec![[0.0, 1.0], [10.0, 0.5]]));
                });

            egui_plot::Plot::new("Plot2")
                .height(plot_height)
                .link_axis("plot_axis", [true, false])
                .link_cursor("plot_cursor", [true, false])
                .show(ui, |ui| {
                    ui.line(Line::new(vec![[5.0, 0.5], [7.0, 1.0]]));
                });
        });
    })
}

Cargo.toml:

[package]
name = "unaligned_plots"
version = "0.1.0"
edition = "2021"

[dependencies]
egui = "0.31"
egui_plot = { git = "https://github.com/emilk/egui_plot", branch = "main" }
eframe = { version = "0.31", default-features = false, features = ["x11", "default_fonts", "wgpu"] }

Expected behavior

The x axis for both the cursor and the plot should be linked even while auto bounds is active.

Screenshots

Image

As can be seen in the image both cursor and plot axis are not aligned properly.

@tripokey tripokey added the bug Something isn't working label Feb 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant