Skip to content

Commit

Permalink
Uset set_ylim auto argument
Browse files Browse the repository at this point in the history
  • Loading branch information
t20100 committed Feb 3, 2025
1 parent 49317a4 commit 82f1969
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions src/silx/gui/plot/backends/BackendMatplotlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -1192,20 +1192,17 @@ def setLimits(self, xmin, xmax, ymin, ymax, y2min=None, y2max=None):
self._dirtyLimits = True
self.ax.set_xlim(min(xmin, xmax), max(xmin, xmax))

keepRatio = self.isKeepDataAspectRatio()
if y2min is not None and y2max is not None:
if self.ax2.get_autoscaley_on():
pass
elif not self.isYAxisInverted():
self.ax2.set_ylim(min(y2min, y2max), max(y2min, y2max))
if not self.isYAxisInverted():
self.ax2.set_ylim(min(y2min, y2max), max(y2min, y2max), auto=keepRatio)
else:
self.ax2.set_ylim(max(y2min, y2max), min(y2min, y2max))
self.ax2.set_ylim(max(y2min, y2max), min(y2min, y2max), auto=keepRatio)

if self.ax.get_autoscaley_on():
pass
elif not self.isYAxisInverted():
self.ax.set_ylim(min(ymin, ymax), max(ymin, ymax))
if not self.isYAxisInverted():
self.ax.set_ylim(min(ymin, ymax), max(ymin, ymax), auto=keepRatio)
else:
self.ax.set_ylim(max(ymin, ymax), min(ymin, ymax))
self.ax.set_ylim(max(ymin, ymax), min(ymin, ymax), auto=keepRatio)

self._updateMarkers()

Expand Down Expand Up @@ -1254,10 +1251,11 @@ def setGraphYLimits(self, ymin, ymax, axis):
xcenter = 0.5 * (xmin + xmax)
ax.set_xlim(xcenter - 0.5 * newXRange, xcenter + 0.5 * newXRange)

keepRatio = self.isKeepDataAspectRatio()
if not self.isYAxisInverted():
ax.set_ylim(ymin, ymax)
ax.set_ylim(ymin, ymax, auto=keepRatio)
else:
ax.set_ylim(ymax, ymin)
ax.set_ylim(ymax, ymin, auto=keepRatio)

self._updateMarkers()

Expand Down Expand Up @@ -1351,8 +1349,6 @@ def isKeepDataAspectRatio(self):
def setKeepDataAspectRatio(self, flag):
self.ax.set_aspect(1.0 if flag else "auto")
self.ax2.set_aspect(1.0 if flag else "auto")
self.ax.set_autoscaley_on(flag)
self.ax2.set_autoscaley_on(flag)

def setGraphGrid(self, which):
self.ax.grid(False, which="both") # Disable all grid first
Expand Down

0 comments on commit 82f1969

Please sign in to comment.