@@ -3143,6 +3143,67 @@ def set_xlim(self, left=None, right=None, emit=True, auto=False, **kw):
3143
3143
self .stale = True
3144
3144
return left , right
3145
3145
3146
+ def _set_xviewlim (self , left = None , right = None , emit = True ):
3147
+ """
3148
+ Set the view limits for the x-axis directly
3149
+
3150
+ .. ACCEPTS: (left: float, right: float)
3151
+
3152
+ Parameters
3153
+ ----------
3154
+ left : scalar, optional
3155
+ The left xlim (default: None, which leaves the left limit
3156
+ unchanged).
3157
+
3158
+ right : scalar, optional
3159
+ The right xlim (default: None, which leaves the right limit
3160
+ unchanged).
3161
+
3162
+ emit : bool, optional
3163
+ Whether to notify observers of limit change (default: True).
3164
+
3165
+ xlimits : tuple, optional
3166
+ The left and right xlims may be passed as the tuple
3167
+ (`left`, `right`) as the first positional argument (or as
3168
+ the `left` keyword argument).
3169
+
3170
+ Returns
3171
+ -------
3172
+ xlimits : tuple
3173
+ Returns the new x-axis view limits as (`left`, `right`).
3174
+
3175
+ Notes
3176
+ -----
3177
+ The `left` value may be greater than the `right` value, in which
3178
+ case the x-axis values will decrease from left to right.
3179
+
3180
+ Examples
3181
+ --------
3182
+ >>> _set_xviewlim(left, right)
3183
+ >>> _set_xviewlim((left, right))
3184
+ >>> left, right = _set_xviewlim(left, right)
3185
+
3186
+ """
3187
+ if right is None and iterable (left ):
3188
+ left , right = left
3189
+ if left is None or right is None :
3190
+ raise ValueError ('Invalid view limits provided: %s, %s' ,
3191
+ left , right )
3192
+
3193
+ self .viewLim .intervalx = (left , right )
3194
+
3195
+ if emit :
3196
+ self .callbacks .process ('xlim_changed' , self )
3197
+ # Call all of the other x-axes that are shared with this one
3198
+ for other in self ._shared_x_axes .get_siblings (self ):
3199
+ if other is not self :
3200
+ other ._set_xviewlim (self .viewLim .intervalx , emit = False )
3201
+ if (other .figure != self .figure and
3202
+ other .figure .canvas is not None ):
3203
+ other .figure .canvas .draw_idle ()
3204
+ self .stale = True
3205
+ return left , right
3206
+
3146
3207
def get_xscale (self ):
3147
3208
return self .xaxis .get_scale ()
3148
3209
get_xscale .__doc__ = "Return the xaxis scale string: %s" "" % (
@@ -3203,12 +3264,6 @@ def set_xticks(self, ticks, minor=False):
3203
3264
"""
3204
3265
ret = self .xaxis .set_ticks (ticks , minor = minor )
3205
3266
self .stale = True
3206
-
3207
- g = self .get_shared_x_axes ()
3208
- for ax in g .get_siblings (self ):
3209
- ax .xaxis .set_ticks (ticks , minor = minor )
3210
- ax .stale = True
3211
-
3212
3267
return ret
3213
3268
3214
3269
def get_xmajorticklabels (self ):
@@ -3296,12 +3351,6 @@ def set_xticklabels(self, labels, fontdict=None, minor=False, **kwargs):
3296
3351
ret = self .xaxis .set_ticklabels (labels ,
3297
3352
minor = minor , ** kwargs )
3298
3353
self .stale = True
3299
-
3300
- g = self .get_shared_x_axes ()
3301
- for ax in g .get_siblings (self ):
3302
- ax .xaxis .set_ticklabels (labels , minor = minor , ** kwargs )
3303
- ax .stale = True
3304
-
3305
3354
return ret
3306
3355
3307
3356
def invert_yaxis (self ):
@@ -3475,6 +3524,62 @@ def set_ylim(self, bottom=None, top=None, emit=True, auto=False, **kw):
3475
3524
self .stale = True
3476
3525
return bottom , top
3477
3526
3527
+ def _set_yviewlim (self , bottom = None , top = None , emit = True ):
3528
+ """
3529
+ Set the view limits for the y-axis directly
3530
+
3531
+ .. ACCEPTS: (bottom: float, top: float)
3532
+
3533
+ Parameters
3534
+ ----------
3535
+ bottom : scalar, optional
3536
+ The bottom ylim (default: None, which leaves the bottom
3537
+ limit unchanged).
3538
+
3539
+ top : scalar, optional
3540
+ The top ylim (default: None, which leaves the top limit
3541
+ unchanged).
3542
+
3543
+ emit : bool, optional
3544
+ Whether to notify observers of limit change (default: True).
3545
+
3546
+ ylimits : tuple, optional
3547
+ The bottom and top yxlims may be passed as the tuple
3548
+ (`bottom`, `top`) as the first positional argument (or as
3549
+ the `bottom` keyword argument).
3550
+
3551
+ Returns
3552
+ -------
3553
+ ylimits : tuple
3554
+ Returns the new y-axis limits as (`bottom`, `top`).
3555
+
3556
+ Examples
3557
+ --------
3558
+ >>> _set_yviewlim(bottom, top)
3559
+ >>> _set_yviewlim((bottom, top))
3560
+ >>> bottom, top = _set_yviewlim(bottom, top)
3561
+ """
3562
+
3563
+ if top is None and iterable (bottom ):
3564
+ bottom , top = bottom
3565
+ if top is None or bottom is None :
3566
+ raise ValueError ('Invalid view limits provided: %s, %s' ,
3567
+ bottom , top )
3568
+
3569
+ self .viewLim .intervaly = (bottom , top )
3570
+
3571
+ if emit :
3572
+ self .callbacks .process ('ylim_changed' , self )
3573
+ # Call all of the other y-axes that are shared with this one
3574
+ for other in self ._shared_y_axes .get_siblings (self ):
3575
+ if other is not self :
3576
+ other ._set_yviewlim (self .viewLim .intervaly , emit = False )
3577
+ if (other .figure != self .figure and
3578
+ other .figure .canvas is not None ):
3579
+ other .figure .canvas .draw_idle ()
3580
+ self .stale = True
3581
+ return bottom , top
3582
+
3478
3583
def get_yscale (self ):
3479
3584
return self .yaxis .get_scale ()
3480
3585
get_yscale .__doc__ = "Return the yaxis scale string: %s" "" % (
@@ -3533,9 +3638,6 @@ def set_yticks(self, ticks, minor=False):
3533
3638
Default is ``False``.
3534
3639
"""
3535
3640
ret = self .yaxis .set_ticks (ticks , minor = minor )
3536
- g = self .get_shared_y_axes ()
3537
- for ax in g .get_siblings (self ):
3538
- ax .yaxis .set_ticks (ticks , minor = minor )
3539
3641
return ret
3540
3642
3541
3643
def get_ymajorticklabels (self ):
@@ -3620,12 +3722,8 @@ def set_yticklabels(self, labels, fontdict=None, minor=False, **kwargs):
3620
3722
"""
3621
3723
if fontdict is not None :
3622
3724
kwargs .update (fontdict )
3623
- ret = self .yaxis .set_ticklabels (labels ,
3725
+ return self .yaxis .set_ticklabels (labels ,
3624
3726
minor = minor , ** kwargs )
3625
- g = self .get_shared_y_axes ()
3626
- for ax in g .get_siblings (self ):
3627
- ax .yaxis .set_ticklabels (labels , minor = minor , ** kwargs )
3628
- return ret
3629
3727
3630
3728
def xaxis_date (self , tz = None ):
3631
3729
"""
0 commit comments