Skip to content

Instantly share code, notes, and snippets.

@bombless
Created October 12, 2025 14:35
Show Gist options
  • Select an option

  • Save bombless/1cc839c7099965f8149e52d17b1580ac to your computer and use it in GitHub Desktop.

Select an option

Save bombless/1cc839c7099965f8149e52d17b1580ac to your computer and use it in GitHub Desktop.
egui_plot 0.34 zooming problem
[package]
name = "custom_plot_manipulation"
version = "0.1.0"
edition = "2024"
[dependencies]
eframe = "0.33"
egui_plot = "0.34"
//! 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