diff --git a/src/function_entry.rs b/src/function_entry.rs index 955c4c2..643d2c4 100644 --- a/src/function_entry.rs +++ b/src/function_entry.rs @@ -1,7 +1,8 @@ use crate::math_app::AppSettings; use crate::misc::{EguiHelper, newtons_method_helper, step_helper}; +use crate::symbolic::try_symbolic; use egui::{Checkbox, Context}; -use egui_plot::{Bar, BarChart, PlotPoint, PlotUi}; +use egui_plot::{Bar, BarChart, PlotPoint, PlotUi, Points}; use epaint::Color32; use parsing::{AutoComplete, generate_hint}; @@ -409,24 +410,42 @@ impl FunctionEntry { // Plot extrema points if settings.do_extrema && !self.extrema_data.is_empty() { - plot_ui.points( - self.extrema_data - .clone() - .to_points() - .color(Color32::YELLOW) - .radius(5.0), // Radius of points of Extrema - ); + for point in &self.extrema_data { + let name = format!( + "({}, {})", + try_symbolic(point.x) + .map(|s| s.to_string()) + .unwrap_or_else(|| format!("{:.4}", point.x)), + try_symbolic(point.y) + .map(|s| s.to_string()) + .unwrap_or_else(|| format!("{:.4}", point.y)) + ); + plot_ui.points( + Points::new(name, vec![[point.x, point.y]]) + .color(Color32::YELLOW) + .radius(5.0), + ); + } } // Plot roots points if settings.do_roots && !self.root_data.is_empty() { - plot_ui.points( - self.root_data - .clone() - .to_points() - .color(Color32::LIGHT_BLUE) - .radius(5.0), // Radius of points of Roots - ); + for point in &self.root_data { + let name = format!( + "({}, {})", + try_symbolic(point.x) + .map(|s| s.to_string()) + .unwrap_or_else(|| format!("{:.4}", point.x)), + try_symbolic(point.y) + .map(|s| s.to_string()) + .unwrap_or_else(|| format!("{:.4}", point.y)) + ); + plot_ui.points( + Points::new(name, vec![[point.x, point.y]]) + .color(Color32::LIGHT_BLUE) + .radius(5.0), + ); + } } if self.nth_derivative diff --git a/src/misc.rs b/src/misc.rs index cd6df10..460b848 100644 --- a/src/misc.rs +++ b/src/misc.rs @@ -1,5 +1,5 @@ -use base64::engine::general_purpose; use base64::Engine; +use base64::engine::general_purpose; use egui_plot::{Line, PlotPoint, PlotPoints, Points}; use emath::Pos2; use itertools::Itertools;