@@ -487,14 +487,14 @@ def __init__(self, fig, rect,
487
487
self ._shared_x_axes .join (self , sharex )
488
488
if sharex ._adjustable == 'box' :
489
489
sharex ._adjustable = 'datalim'
490
- #warnings.warn(
490
+ # warnings.warn(
491
491
# 'shared axes: "adjustable" is being changed to "datalim"')
492
492
self ._adjustable = 'datalim'
493
493
if sharey is not None :
494
494
self ._shared_y_axes .join (self , sharey )
495
495
if sharey ._adjustable == 'box' :
496
496
sharey ._adjustable = 'datalim'
497
- #warnings.warn(
497
+ # warnings.warn(
498
498
# 'shared axes: "adjustable" is being changed to "datalim"')
499
499
self ._adjustable = 'datalim'
500
500
self .set_label (label )
@@ -1003,11 +1003,11 @@ def cla(self):
1003
1003
1004
1004
self .grid (False ) # Disable grid on init to use rcParameter
1005
1005
self .grid (self ._gridOn , which = rcParams ['axes.grid.which' ],
1006
- axis = rcParams ['axes.grid.axis' ])
1006
+ axis = rcParams ['axes.grid.axis' ])
1007
1007
props = font_manager .FontProperties (
1008
- size = rcParams ['axes.titlesize' ],
1009
- weight = rcParams ['axes.titleweight' ]
1010
- )
1008
+ size = rcParams ['axes.titlesize' ],
1009
+ weight = rcParams ['axes.titleweight' ]
1010
+ )
1011
1011
1012
1012
self .titleOffsetTrans = mtransforms .ScaledTranslation (
1013
1013
0.0 , 5.0 / 72.0 , self .figure .dpi_scale_trans )
@@ -1122,7 +1122,7 @@ def set_color_cycle(self, clist):
1122
1122
.. deprecated:: 1.5
1123
1123
"""
1124
1124
cbook .warn_deprecated (
1125
- '1.5' , name = 'set_color_cycle' , alternative = 'set_prop_cycle' )
1125
+ '1.5' , name = 'set_color_cycle' , alternative = 'set_prop_cycle' )
1126
1126
self .set_prop_cycle ('color' , clist )
1127
1127
1128
1128
def ishold (self ):
@@ -3323,8 +3323,12 @@ def _set_view_from_bbox(self, bbox, direction='in',
3323
3323
Parameters
3324
3324
----------
3325
3325
3326
- bbox : tuple
3327
- The selected bounding box limits, in *display* coordinates.
3326
+ bbox : 4-tuple or 3 tuple
3327
+ * If bbox is a 4 tuple, it is the selected bounding box limits,
3328
+ in *display* coordinates.
3329
+ * If bbox is a 3 tuple, it is an (xp, yp, scl) triple, where
3330
+ (xp,yp) is the center of zooming and scl the scale factor to
3331
+ zoom by.
3328
3332
3329
3333
direction : str
3330
3334
The direction to apply the bounding box.
@@ -3343,15 +3347,52 @@ def _set_view_from_bbox(self, bbox, direction='in',
3343
3347
twiny : bool
3344
3348
Whether this axis is twinned in the *y*-direction.
3345
3349
"""
3350
+ Xmin , Xmax = self .get_xlim ()
3351
+ Ymin , Ymax = self .get_ylim ()
3352
+
3353
+ if len (bbox ) == 3 :
3354
+ # Zooming code
3355
+ xp , yp , scl = bbox
3356
+
3357
+ # Should not happen
3358
+ if scl == 0 :
3359
+ scl = 1.
3346
3360
3361
+ # direction = 'in'
3362
+ if scl > 1 :
3363
+ direction = 'in'
3364
+ else :
3365
+ direction = 'out'
3366
+ scl = 1 / scl
3367
+
3368
+ # get the limits of the axes
3369
+ tranD2C = self .transData .transform
3370
+ xmin , ymin = tranD2C ((Xmin , Ymin ))
3371
+ xmax , ymax = tranD2C ((Xmax , Ymax ))
3372
+
3373
+ # set the range
3374
+ xwidth = xmax - xmin
3375
+ ywidth = ymax - ymin
3376
+ xcen = (xmax + xmin )* .5
3377
+ ycen = (ymax + ymin )* .5
3378
+ xzc = (xp * (scl - 1 ) + xcen )/ scl
3379
+ yzc = (yp * (scl - 1 ) + ycen )/ scl
3380
+
3381
+ bbox = [xzc - xwidth / 2. / scl , yzc - ywidth / 2. / scl ,
3382
+ xzc + xwidth / 2. / scl , yzc + ywidth / 2. / scl ]
3383
+ elif len (bbox ) != 4 :
3384
+ # should be len 3 or 4 but nothing else
3385
+ warnings .warn ('Warning in _set_view_from_bbox: bounding box is not a\
3386
+ tuple of length 3 or 4. Ignoring the view change...' )
3387
+ return
3388
+
3389
+ # Just grab bounding box
3347
3390
lastx , lasty , x , y = bbox
3348
3391
3349
3392
# zoom to rect
3350
3393
inverse = self .transData .inverted ()
3351
3394
lastx , lasty = inverse .transform_point ((lastx , lasty ))
3352
3395
x , y = inverse .transform_point ((x , y ))
3353
- Xmin , Xmax = self .get_xlim ()
3354
- Ymin , Ymax = self .get_ylim ()
3355
3396
3356
3397
if twinx :
3357
3398
x0 , x1 = Xmin , Xmax
0 commit comments