Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita118261

Browse files
committed
ENH: Update view limits on units change
This adds a independent callback for units changes that both updates thedata limits (relim) as well as the view limits (autoscale_view).
1 parent3b97e55 commita118261

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

‎lib/matplotlib/axes/_base.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -556,11 +556,11 @@ def __init__(self, fig, rect,
556556

557557
ifself.xaxisisnotNone:
558558
self._xcid=self.xaxis.callbacks.connect('units finalize',
559-
self.relim)
559+
self._on_units_changed)
560560

561561
ifself.yaxisisnotNone:
562562
self._ycid=self.yaxis.callbacks.connect('units finalize',
563-
self.relim)
563+
self._on_units_changed)
564564

565565
self.tick_params(
566566
top=rcParams['xtick.top']andrcParams['xtick.minor.top'],
@@ -1890,6 +1890,15 @@ def add_container(self, container):
18901890
container.set_remove_method(lambdah:self.containers.remove(h))
18911891
returncontainer
18921892

1893+
def_on_units_changed(self):
1894+
"""
1895+
Callback for processing changes to axis units.
1896+
1897+
Currently forces updates of data limits and view limits.
1898+
"""
1899+
self.relim()
1900+
self.autoscale_view()
1901+
18931902
defrelim(self,visible_only=False):
18941903
"""
18951904
Recompute the data limits based on current artists. If you want to

‎lib/matplotlib/tests/test_units.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ def convert(value, unit, axis):
7575
ax.axvline(Quantity(120,'minutes'),color='tab:green')
7676
ax.yaxis.set_units('inches')
7777
ax.xaxis.set_units('seconds')
78-
ax.autoscale_view()
7978

8079
assertqc.convert.called
8180
assertqc.axisinfo.called

‎lib/mpl_toolkits/mplot3d/axes3d.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def __init__(self, fig, rect=None, *args, **kwargs):
115115

116116
ifself.zaxisisnotNone :
117117
self._zcid=self.zaxis.callbacks.connect('units finalize',
118-
self.relim)
118+
self._on_units_changed)
119119
else :
120120
self._zcid=None
121121

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp