@@ -552,6 +552,7 @@ def __init__(self, plot, parent=None):
552
552
for axis in (self .ax .yaxis , self .ax .xaxis , self .ax2 .yaxis , self .ax2 .xaxis ):
553
553
axis .set_major_formatter (DefaultTickFormatter ())
554
554
555
+ self .ax .set_autoscaley_on (True )
555
556
self .ax2 .set_autoscaley_on (True )
556
557
557
558
# this works but the figure color is left
@@ -1193,19 +1194,9 @@ def setLimits(self, xmin, xmax, ymin, ymax, y2min=None, y2max=None):
1193
1194
self .ax .set_xlim (min (xmin , xmax ), max (xmin , xmax ))
1194
1195
1195
1196
if y2min is not None and y2max is not None :
1196
- if self .ax2 .get_autoscaley_on ():
1197
- pass
1198
- elif not self .isYAxisInverted ():
1199
- self .ax2 .set_ylim (min (y2min , y2max ), max (y2min , y2max ))
1200
- else :
1201
- self .ax2 .set_ylim (max (y2min , y2max ), min (y2min , y2max ))
1197
+ self .ax2 .set_ybound (y2min , y2max )
1202
1198
1203
- if self .ax .get_autoscaley_on ():
1204
- pass
1205
- elif not self .isYAxisInverted ():
1206
- self .ax .set_ylim (min (ymin , ymax ), max (ymin , ymax ))
1207
- else :
1208
- self .ax .set_ylim (max (ymin , ymax ), min (ymin , ymax ))
1199
+ self .ax .set_ybound (ymin , ymax )
1209
1200
1210
1201
self ._updateMarkers ()
1211
1202
@@ -1237,8 +1228,6 @@ def getGraphYLimits(self, axis):
1237
1228
1238
1229
def setGraphYLimits (self , ymin , ymax , axis ):
1239
1230
ax = self .ax2 if axis == "right" else self .ax
1240
- if ymax < ymin :
1241
- ymin , ymax = ymax , ymin
1242
1231
self ._dirtyLimits = True
1243
1232
1244
1233
if self .isKeepDataAspectRatio ():
@@ -1250,14 +1239,11 @@ def setGraphYLimits(self, ymin, ymax, axis):
1250
1239
xmin , xmax = ax .get_xbound ()
1251
1240
curYMin , curYMax = ax .get_ybound ()
1252
1241
1253
- newXRange = (xmax - xmin ) * (ymax - ymin ) / (curYMax - curYMin )
1242
+ newXRange = (xmax - xmin ) * abs (ymax - ymin ) / (curYMax - curYMin )
1254
1243
xcenter = 0.5 * (xmin + xmax )
1255
1244
ax .set_xlim (xcenter - 0.5 * newXRange , xcenter + 0.5 * newXRange )
1256
1245
1257
- if not self .isYAxisInverted ():
1258
- ax .set_ylim (ymin , ymax )
1259
- else :
1260
- ax .set_ylim (ymax , ymin )
1246
+ ax .set_ybound (ymin , ymax )
1261
1247
1262
1248
self ._updateMarkers ()
1263
1249
@@ -1319,7 +1305,7 @@ def setYAxisLogarithmic(self, flag):
1319
1305
dataRange = self ._plot .getDataRange ()[dataRangeIndex ]
1320
1306
if dataRange is None :
1321
1307
dataRange = 1 , 100 # Fallback
1322
- axis .set_ylim (* dataRange )
1308
+ axis .set_ybound (* dataRange )
1323
1309
redraw = True
1324
1310
if redraw :
1325
1311
self .draw ()
@@ -1351,8 +1337,6 @@ def isKeepDataAspectRatio(self):
1351
1337
def setKeepDataAspectRatio (self , flag ):
1352
1338
self .ax .set_aspect (1.0 if flag else "auto" )
1353
1339
self .ax2 .set_aspect (1.0 if flag else "auto" )
1354
- self .ax .set_autoscaley_on (flag )
1355
- self .ax2 .set_autoscaley_on (flag )
1356
1340
1357
1341
def setGraphGrid (self , which ):
1358
1342
self .ax .grid (False , which = "both" ) # Disable all grid first
0 commit comments