@@ -1134,6 +1134,7 @@ def cla(self):
1134
1134
self ._ymargin = mpl .rcParams ['axes.ymargin' ]
1135
1135
self ._tight = None
1136
1136
self ._use_sticky_edges = True
1137
+ self ._force_sticky_edges = False
1137
1138
self ._update_transScale () # needed?
1138
1139
1139
1140
self ._get_lines = _process_plot_var_args (self )
@@ -2328,6 +2329,29 @@ def use_sticky_edges(self, b):
2328
2329
self ._use_sticky_edges = bool (b )
2329
2330
# No effect until next autoscaling, which will mark the axes as stale.
2330
2331
2332
+ @property
2333
+ def force_sticky_edges (self ):
2334
+ """
2335
+ When autoscaling, whether to enforce `Artist.sticky_edges`
2336
+ values.
2337
+
2338
+ Default is ``False``.
2339
+
2340
+ By default, when ``sticky_edges`` are present the tighter
2341
+ marging is used between the "automatic" and the "sticky".
2342
+ Setting this to ``True`` forces the use of the specified margins,
2343
+ even if sticky_edge value is far away from datalim.
2344
+
2345
+ The changing this property does not change the plot until
2346
+ `autoscale` or `autoscale_view` is called.
2347
+ """
2348
+ return self ._force_sticky_edges
2349
+
2350
+ @use_sticky_edges .setter
2351
+ def force_sticky_edges (self , b ):
2352
+ self ._force_sticky_edges = bool (b )
2353
+ # No effect until next autoscaling, which will mark the axes as stale.
2354
+
2331
2355
def set_xmargin (self , m ):
2332
2356
"""
2333
2357
Set padding of X data limits prior to autoscaling.
@@ -2571,7 +2595,6 @@ def autoscale_view(self, tight=None, scalex=True, scaley=True):
2571
2595
2572
2596
def handle_single_axis (scale , autoscaleon , shared_axes , interval ,
2573
2597
minpos , axis , margin , stickies , set_bound ):
2574
-
2575
2598
if not (scale and autoscaleon ):
2576
2599
return # nothing to do...
2577
2600
@@ -2620,11 +2643,11 @@ def handle_single_axis(scale, autoscaleon, shared_axes, interval,
2620
2643
x0 , x1 = inverse_trans .transform ([x0t - delta , x1t + delta ])
2621
2644
2622
2645
# Apply sticky bounds.
2646
+ _f = self ._force_sticky_edges
2623
2647
if x0bound is not None :
2624
- x0 = max (x0 , x0bound )
2648
+ x0 = max (x0 , x0bound ) if not _f else x0bound
2625
2649
if x1bound is not None :
2626
- x1 = min (x1 , x1bound )
2627
-
2650
+ x1 = min (x1 , x1bound ) if not _f else x1bound
2628
2651
if not self ._tight :
2629
2652
x0 , x1 = locator .view_limits (x0 , x1 )
2630
2653
set_bound (x0 , x1 )
0 commit comments