@@ -94,6 +94,7 @@ def __init__(
94
94
self .zz_viewLim = Bbox .unit ()
95
95
self .xy_dataLim = Bbox .unit ()
96
96
self .zz_dataLim = Bbox .unit ()
97
+ self ._stale_viewlim_z = False
97
98
98
99
# inhibit autoscale_view until the axes are defined
99
100
# they can't be defined until Axes.__init__ has been called
@@ -232,6 +233,24 @@ def w_zaxis(self):
232
233
def _get_axis_list (self ):
233
234
return super ()._get_axis_list () + (self .zaxis , )
234
235
236
+ def _unstale_viewLim (self ):
237
+ # We should arrange to store this information once per share-group
238
+ # instead of on every axis.
239
+ scalex = any (ax ._stale_viewlim_x
240
+ for ax in self ._shared_x_axes .get_siblings (self ))
241
+ scaley = any (ax ._stale_viewlim_y
242
+ for ax in self ._shared_y_axes .get_siblings (self ))
243
+ scalez = any (ax ._stale_viewlim_z
244
+ for ax in self ._shared_z_axes .get_siblings (self ))
245
+ if scalex or scaley or scalez :
246
+ for ax in self ._shared_x_axes .get_siblings (self ):
247
+ ax ._stale_viewlim_x = False
248
+ for ax in self ._shared_y_axes .get_siblings (self ):
249
+ ax ._stale_viewlim_y = False
250
+ for ax in self ._shared_z_axes .get_siblings (self ):
251
+ ax ._stale_viewlim_z = False
252
+ self .autoscale_view (scalex = scalex , scaley = scaley , scalez = scalez )
253
+
235
254
def unit_cube (self , vals = None ):
236
255
minx , maxx , miny , maxy , minz , maxz = vals or self .get_w_lims ()
237
256
return [(minx , miny , minz ),
@@ -416,6 +435,8 @@ def apply_aspect(self, position=None):
416
435
417
436
@artist .allow_rasterization
418
437
def draw (self , renderer ):
438
+ self ._unstale_viewLim ()
439
+
419
440
# draw the background patch
420
441
self .patch .draw (renderer )
421
442
self ._frameon = False
@@ -480,7 +501,8 @@ def _on_units_changed(self, scalex=False, scaley=False, scalez=False):
480
501
Currently forces updates of data limits and view limits.
481
502
"""
482
503
self .relim ()
483
- self .autoscale_view (scalex = scalex , scaley = scaley , scalez = scalez )
504
+ self ._request_autoscale_view (scalex = scalex , scaley = scaley ,
505
+ scalez = scalez )
484
506
485
507
def update_datalim (self , xys , ** kwargs ):
486
508
pass
@@ -529,6 +551,24 @@ def set_autoscalez_on(self, b):
529
551
"""
530
552
self ._autoscaleZon = b
531
553
554
+ def set_xmargin (self , m ):
555
+ # docstring inherited
556
+ scalez = self ._stale_viewlim_z
557
+ super ().set_xmargin (m )
558
+ # Superclass is 2D and will call _request_autoscale_view with defaults
559
+ # for unknown Axis, which would be scalez=True, but it shouldn't be for
560
+ # this call, so restore it.
561
+ self ._stale_viewlim_z = scalez
562
+
563
+ def set_ymargin (self , m ):
564
+ # docstring inherited
565
+ scalez = self ._stale_viewlim_z
566
+ super ().set_ymargin (m )
567
+ # Superclass is 2D and will call _request_autoscale_view with defaults
568
+ # for unknown Axis, which would be scalez=True, but it shouldn't be for
569
+ # this call, so restore it.
570
+ self ._stale_viewlim_z = scalez
571
+
532
572
def set_zmargin (self , m ):
533
573
"""
534
574
Set padding of Z data limits prior to autoscaling.
@@ -543,6 +583,7 @@ def set_zmargin(self, m):
543
583
if m < 0 or m > 1 :
544
584
raise ValueError ("margin must be in range 0 to 1" )
545
585
self ._zmargin = m
586
+ self ._request_autoscale_view (scalex = False , scaley = False , scalez = True )
546
587
self .stale = True
547
588
548
589
def margins (self , * margins , x = None , y = None , z = None , tight = True ):
@@ -640,8 +681,8 @@ def autoscale(self, enable=True, axis='both', tight=None):
640
681
self ._autoscaleZon = scalez = bool (enable )
641
682
else :
642
683
scalez = False
643
- self .autoscale_view (tight = tight , scalex = scalex , scaley = scaley ,
644
- scalez = scalez )
684
+ self ._request_autoscale_view (tight = tight , scalex = scalex , scaley = scaley ,
685
+ scalez = scalez )
645
686
646
687
def auto_scale_xyz (self , X , Y , Z = None , had_data = None ):
647
688
# This updates the bounding boxes as to keep a record as to what the
@@ -657,6 +698,19 @@ def auto_scale_xyz(self, X, Y, Z=None, had_data=None):
657
698
# Let autoscale_view figure out how to use this data.
658
699
self .autoscale_view ()
659
700
701
+ # API could be better, right now this is just to match the old calls to
702
+ # autoscale_view() after each plotting method.
703
+ def _request_autoscale_view (self , tight = None , scalex = True , scaley = True ,
704
+ scalez = True ):
705
+ if tight is not None :
706
+ self ._tight = tight
707
+ if scalex :
708
+ self ._stale_viewlim_x = True # Else keep old state.
709
+ if scaley :
710
+ self ._stale_viewlim_y = True
711
+ if scalez :
712
+ self ._stale_viewlim_z = True
713
+
660
714
def autoscale_view (self , tight = None , scalex = True , scaley = True ,
661
715
scalez = True ):
662
716
"""
@@ -767,6 +821,9 @@ def set_xlim3d(self, left=None, right=None, emit=True, auto=False,
767
821
left , right = sorted ([left , right ], reverse = bool (reverse ))
768
822
self .xy_viewLim .intervalx = (left , right )
769
823
824
+ # Mark viewlims as no longer stale without triggering an autoscale.
825
+ for ax in self ._shared_x_axes .get_siblings (self ):
826
+ ax ._stale_viewlim_x = False
770
827
if auto is not None :
771
828
self ._autoscaleXon = bool (auto )
772
829
@@ -822,6 +879,9 @@ def set_ylim3d(self, bottom=None, top=None, emit=True, auto=False,
822
879
bottom , top = top , bottom
823
880
self .xy_viewLim .intervaly = (bottom , top )
824
881
882
+ # Mark viewlims as no longer stale without triggering an autoscale.
883
+ for ax in self ._shared_y_axes .get_siblings (self ):
884
+ ax ._stale_viewlim_y = False
825
885
if auto is not None :
826
886
self ._autoscaleYon = bool (auto )
827
887
@@ -877,6 +937,9 @@ def set_zlim3d(self, bottom=None, top=None, emit=True, auto=False,
877
937
bottom , top = top , bottom
878
938
self .zz_viewLim .intervalx = (bottom , top )
879
939
940
+ # Mark viewlims as no longer stale without triggering an autoscale.
941
+ for ax in self ._shared_z_axes .get_siblings (self ):
942
+ ax ._stale_viewlim_z = False
880
943
if auto is not None :
881
944
self ._autoscaleZon = bool (auto )
882
945
@@ -1333,7 +1396,8 @@ def locator_params(self, axis='both', tight=None, **kwargs):
1333
1396
self .yaxis .get_major_locator ().set_params (** kwargs )
1334
1397
if _z :
1335
1398
self .zaxis .get_major_locator ().set_params (** kwargs )
1336
- self .autoscale_view (tight = tight , scalex = _x , scaley = _y , scalez = _z )
1399
+ self ._request_autoscale_view (tight = tight , scalex = _x , scaley = _y ,
1400
+ scalez = _z )
1337
1401
1338
1402
def tick_params (self , axis = 'both' , ** kwargs ):
1339
1403
"""
0 commit comments