Created
October 12, 2025 14:35
-
-
Save bombless/1cc839c7099965f8149e52d17b1580ac to your computer and use it in GitHub Desktop.
egui_plot 0.34 zooming problem
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [package] | |
| name = "custom_plot_manipulation" | |
| version = "0.1.0" | |
| edition = "2024" | |
| [dependencies] | |
| eframe = "0.33" | |
| egui_plot = "0.34" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //! This example shows how to implement custom gestures to pan and zoom in the plot | |
| #![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release | |
| use eframe::egui; | |
| use egui_plot::{Line, PlotPoints}; | |
| fn main() -> eframe::Result { | |
| let options = eframe::NativeOptions::default(); | |
| eframe::run_native( | |
| "Plot", | |
| options, | |
| Box::new(|_cc| Ok(Box::<PlotExample>::default())), | |
| ) | |
| } | |
| struct PlotExample { | |
| } | |
| impl Default for PlotExample { | |
| fn default() -> Self { | |
| Self { | |
| } | |
| } | |
| } | |
| impl eframe::App for PlotExample { | |
| fn update(&mut self, ctx: &egui::Context, _: &mut eframe::Frame) { | |
| egui::CentralPanel::default().show(ctx, |ui| { | |
| egui_plot::Plot::new("plot") | |
| .allow_zoom(true) | |
| .allow_drag(false) | |
| .allow_scroll(false) | |
| .auto_bounds([false, false]) | |
| .show(ui, |plot_ui| { | |
| let sine_points = PlotPoints::from_explicit_callback(|x| x.sin(), .., 5000); | |
| let sine_line = Line::new("Sine", sine_points).name("Sine"); | |
| plot_ui.line(sine_line); | |
| }); | |
| }); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment