Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f9e71a5

Browse files
authored
Merge pull request #14640 from jklymak/fix-non-linear-secondary-axis
FIX: allow secondary axes to be non-linear
2 parents db06a34 + c373535 commit f9e71a5

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

lib/matplotlib/axes/_secondary_axes.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,8 @@ def set_functions(self, functions):
222222
'must be a two-tuple of callable functions '
223223
'with the first function being the transform '
224224
'and the second being the inverse')
225-
set_scale(defscale, functions=self._functions)
225+
# need to invert the roles here for the ticks to line up.
226+
set_scale(defscale, functions=self._functions[::-1])
226227

227228
def draw(self, renderer=None, inframe=False):
228229
"""
@@ -262,7 +263,8 @@ def _set_scale(self):
262263
if self._ticks_set:
263264
ticks = self._axis.get_ticklocs()
264265

265-
set_scale(defscale, functions=self._functions)
266+
# need to invert the roles here for the ticks to line up.
267+
set_scale(defscale, functions=self._functions[::-1])
266268

267269
# OK, set_scale sets the locators, but if we've called
268270
# axsecond.set_ticks, we want to keep those.
Loading

0 commit comments

Comments
 (0)