From 70f56d8a40c6312639f8d611b6125a30bf0ed801 Mon Sep 17 00:00:00 2001 From: epezent Date: Wed, 2 Sep 2020 16:02:51 -0500 Subject: [PATCH] add quick fix for fitting data when data is a flat line (see #50) --- implot.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/implot.cpp b/implot.cpp index 5ba1bcb..e113c87 100644 --- a/implot.cpp +++ b/implot.cpp @@ -161,14 +161,14 @@ const char* GetMarkerName(ImPlotMarker marker) { case ImPlotMarker_None: return "None"; case ImPlotMarker_Circle: return "Circle"; case ImPlotMarker_Square: return "Square"; - case ImPlotMarker_Diamond: return "Diamond"; - case ImPlotMarker_Up: return "Up"; - case ImPlotMarker_Down: return "Down"; - case ImPlotMarker_Left: return "Left"; - case ImPlotMarker_Right: return "Right"; - case ImPlotMarker_Cross: return "Cross"; - case ImPlotMarker_Plus: return "Plus"; - case ImPlotMarker_Asterisk: return "Asterisk"; + case ImPlotMarker_Diamond: return "Diamond"; + case ImPlotMarker_Up: return "Up"; + case ImPlotMarker_Down: return "Down"; + case ImPlotMarker_Left: return "Left"; + case ImPlotMarker_Right: return "Right"; + case ImPlotMarker_Cross: return "Cross"; + case ImPlotMarker_Plus: return "Plus"; + case ImPlotMarker_Asterisk: return "Asterisk"; default: return ""; } } @@ -1604,6 +1604,10 @@ void EndPlot() { if (gp.FitY[i] && !ImHasFlag(plot.YAxis[i].Flags, ImPlotAxisFlags_LockMax) && !NanOrInf(gp.ExtentsY[i].Max)) { plot.YAxis[i].Range.Max = gp.ExtentsY[i].Max; } + if ((plot.YAxis[i].Range.Max - plot.YAxis[i].Range.Min) <= (2.0 * FLT_EPSILON)) { + plot.YAxis[i].Range.Max += FLT_EPSILON; + plot.YAxis[i].Range.Min -= FLT_EPSILON; + } } }