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

PlotUi::set_plot_bounds do not change Plot bounds properly #2652

Closed
lvaroqui opened this issue Jan 30, 2023 · 0 comments · Fixed by #2653
Closed

PlotUi::set_plot_bounds do not change Plot bounds properly #2652

lvaroqui opened this issue Jan 30, 2023 · 0 comments · Fixed by #2653
Labels
bug Something is broken

Comments

@lvaroqui
Copy link
Contributor

Bug still present in latest master ✅

Describe the bug

PlotUi::set_plot_bounds and PlotUi::translate_bounds do not change Plot bounds properly.

To Reproduce
Steps to reproduce the behavior:

  1. Run the following code without persistence (which tends to hide the problem):
let sin: PlotPoints = (0..1000)
                .map(|i| {
                    let x = i as f64 * 0.01;
                    [x, x.sin()]
                })
                .collect();
            let line = Line::new(sin);
            Plot::new("my_plot")
                .view_aspect(2.0)
                .allow_boxed_zoom(false)
                .allow_double_click_reset(false)
                .allow_drag(false)
                .allow_scroll(false)
                .allow_zoom(false)
                .show(ui, |plot_ui| {
                    plot_ui.set_plot_bounds(PlotBounds::from_min_max([-1., -1.], [1., 1.]));
                    plot_ui.line(line)
                });

Expected behavior
I'd expect the plot to have [-1., -1.], [1., 1.] bounds, however it defaults to showing the whole line as is the default behavior.

Screenshots

Desktop:

  • OS: Ubuntu
  • Version: 22.04

Additional context
After some digging, I found out that the PlotUi::set_plot_bounds and PlotUi::translate_bounds do not enable the bounds_modified variable, which then makes PlotUi fall back to min_auto_bounds. (see here)

I have a fix that I will share with a PR.

@lvaroqui lvaroqui added the bug Something is broken label Jan 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is broken
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant