File tree 1 file changed +15
-0
lines changed
1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -1242,6 +1242,21 @@ def ignore(self, event):
1242
1242
if self .eventpress == None :
1243
1243
return event .inaxes != self .ax
1244
1244
1245
+ # If a button was pressed, check if the release-button is the
1246
+ # same. If event is out of axis, limit the data coordinates to axes
1247
+ # boundaries.
1248
+ if event .button == self .eventpress .button and event .inaxes != self .ax :
1249
+ (xdata , ydata ) = self .ax .transData .inverted ().transform_point ((event .x , event .y ))
1250
+ xlim = self .ax .get_xlim ()
1251
+ ylim = self .ax .get_ylim ()
1252
+ if xdata < xlim [0 ]: xdata = xlim [0 ]
1253
+ if xdata > xlim [1 ]: xdata = xlim [1 ]
1254
+ if ydata < ylim [0 ]: ydata = ylim [0 ]
1255
+ if ydata > ylim [1 ]: ydata = ylim [1 ]
1256
+ event .xdata = xdata
1257
+ event .ydata = ydata
1258
+ return False
1259
+
1245
1260
# If a button was pressed, check if the release-button is the
1246
1261
# same.
1247
1262
return (event .inaxes != self .ax or
You can’t perform that action at this time.
0 commit comments