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

Commit650323a

Browse files
committed
In SecondaryAxis.set_functions, reuse _set_scale's parent scale caching.
_set_scale checks whether the parent scale changed before modifying thesecondary scale. set_functions should do the same. See added test forpreviously failing case.
1 parentb53418e commit650323a

File tree

2 files changed

+11
-17
lines changed

2 files changed

+11
-17
lines changed

‎lib/matplotlib/axes/_secondary_axes.py

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -215,23 +215,7 @@ def set_functions(self, functions):
215215
216216
If a transform is supplied, then the transform must have an
217217
inverse.
218-
219218
"""
220-
221-
ifself._orientation=='x':
222-
set_scale=self.set_xscale
223-
parent_scale=self._parent.get_xscale()
224-
else:
225-
set_scale=self.set_yscale
226-
parent_scale=self._parent.get_yscale()
227-
# we need to use a modified scale so the scale can receive the
228-
# transform. Only types supported are linear and log10 for now.
229-
# Probably possible to add other transforms as a todo...
230-
ifparent_scale=='log':
231-
defscale='functionlog'
232-
else:
233-
defscale='function'
234-
235219
if (isinstance(functions,tuple)andlen(functions)==2and
236220
callable(functions[0])andcallable(functions[1])):
237221
# make an arbitrary convert from a two-tuple of functions
@@ -244,7 +228,7 @@ def set_functions(self, functions):
244228
'must be a two-tuple of callable functions '
245229
'with the first function being the transform '
246230
'and the second being the inverse')
247-
set_scale(defscale,functions=self._functions)
231+
self._set_scale()
248232

249233
defdraw(self,renderer=None,inframe=False):
250234
"""

‎lib/matplotlib/tests/test_axes.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6135,6 +6135,16 @@ def invert(x):
61356135
mticker.NullLocator)
61366136

61376137

6138+
deftest_secondary_formatter():
6139+
fig,ax=plt.subplots()
6140+
ax.set_xscale("log")
6141+
secax=ax.secondary_xaxis("top")
6142+
secax.xaxis.set_major_formatter(mticker.ScalarFormatter())
6143+
fig.canvas.draw()
6144+
assertisinstance(
6145+
secax.xaxis.get_major_formatter(),mticker.ScalarFormatter)
6146+
6147+
61386148
defcolor_boxes(fig,axs):
61396149
"""
61406150
Helper for the tests below that test the extents of various axes elements

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp