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

Skip to content

Commit 0f9f85f

Browse files
committed
Merge remote-tracking branch 'dmcdougall/fix_format'
Conflicts: doc/api/api_changes.rst
2 parents 43dc729 + 6a2d1e9 commit 0f9f85f

File tree

6 files changed

+1274
-0
lines changed

6 files changed

+1274
-0
lines changed

doc/api/api_changes.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ Changes in 1.2.x
1818
when specifying a marker using a tuple, the angle is now specified
1919
in degrees, not radians.
2020

21+
* Using :meth:`~matplotlib.axes.Axes.twinx` or
22+
:meth:`~matplotlib.axes.Axes.twiny` no longer overrides the current locaters
23+
and formatters on the axes.
24+
2125
* In :meth:`~matplotlib.axes.Axes.contourf`, the handling of the *extend*
2226
kwarg has changed. Formerly, the extended ranges were mapped
2327
after to 0, 1 after being normed, so that they always corresponded

lib/matplotlib/axes.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -868,7 +868,21 @@ def cla(self):
868868
self.xaxis.minor = self._sharex.xaxis.minor
869869
x0, x1 = self._sharex.get_xlim()
870870
self.set_xlim(x0, x1, emit=False, auto=None)
871+
872+
# Save the current formatter/locator so we don't lose it
873+
majf = self._sharex.xaxis.get_major_formatter()
874+
minf = self._sharex.xaxis.get_minor_formatter()
875+
majl = self._sharex.xaxis.get_major_locator()
876+
minl = self._sharex.xaxis.get_minor_locator()
877+
878+
# This overwrites the current formatter/locator
871879
self.xaxis.set_scale(self._sharex.xaxis.get_scale())
880+
881+
# Reset the formatter/locator
882+
self.xaxis.set_major_formatter(majf)
883+
self.xaxis.set_minor_formatter(minf)
884+
self.xaxis.set_major_locator(majl)
885+
self.xaxis.set_minor_locator(minl)
872886
else:
873887
self.xaxis.set_scale('linear')
874888

@@ -877,7 +891,21 @@ def cla(self):
877891
self.yaxis.minor = self._sharey.yaxis.minor
878892
y0, y1 = self._sharey.get_ylim()
879893
self.set_ylim(y0, y1, emit=False, auto=None)
894+
895+
# Save the current formatter/locator so we don't lose it
896+
majf = self._sharey.yaxis.get_major_formatter()
897+
minf = self._sharey.yaxis.get_minor_formatter()
898+
majl = self._sharey.yaxis.get_major_locator()
899+
minl = self._sharey.yaxis.get_minor_locator()
900+
901+
# This overwrites the current formatter/locator
880902
self.yaxis.set_scale(self._sharey.yaxis.get_scale())
903+
904+
# Reset the formatter/locator
905+
self.yaxis.set_major_formatter(majf)
906+
self.yaxis.set_minor_formatter(minf)
907+
self.yaxis.set_major_locator(majl)
908+
self.yaxis.set_minor_locator(minl)
881909
else:
882910
self.yaxis.set_scale('linear')
883911

Binary file not shown.

0 commit comments

Comments
 (0)