Skip to content

Commit 3109940

Browse files
committed
handle equal axis edge case when user sets x limits
1 parent 4edb1c7 commit 3109940

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

implot.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1453,8 +1453,15 @@ bool BeginPlot(const char* title, const char* x_label, const char* y1_label, con
14531453
if (ImHasFlag(plot.Flags, ImPlotFlags_Equal)) {
14541454
double xar = plot.XAxis.GetAspect();
14551455
double yar = plot.YAxis[0].GetAspect();
1456-
if (!ImAlmostEqual(xar,yar) && !plot.YAxis[0].IsInputLocked())
1457-
plot.XAxis.SetAspect(yar);
1456+
// edge case: user has set x range this frame, so fit y to x so that we honor their request for x range
1457+
// NB: because of feedback across several frames, the user's x request may not be perfectly honored
1458+
if (gp.NextPlotData.HasXRange) {
1459+
plot.YAxis[0].SetAspect(xar);
1460+
}
1461+
else {
1462+
if (!ImAlmostEqual(xar,yar) && !plot.YAxis[0].IsInputLocked())
1463+
plot.XAxis.SetAspect(yar);
1464+
}
14581465
}
14591466

14601467
// AXIS COLORS -----------------------------------------------------------------

0 commit comments

Comments
 (0)