Skip to content

Commit c240932

Browse files
committed
Fix overwrite of the minor formatters and locaters
1 parent 62dc662 commit c240932

File tree

1 file changed

+22
-10
lines changed

1 file changed

+22
-10
lines changed

lib/matplotlib/axes.py

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -853,14 +853,20 @@ def cla(self):
853853
x0, x1 = self._sharex.get_xlim()
854854
self.set_xlim(x0, x1, emit=False, auto=None)
855855

856-
# Save the current formatter so we don't lose it
857-
frmt = self._sharex.xaxis.get_major_formatter()
856+
# Save the current formatter/locator so we don't lose it
857+
majf = self._sharex.xaxis.get_major_formatter()
858+
minf = self._sharex.xaxis.get_minor_formatter()
859+
majl = self._sharex.xaxis.get_major_locator()
860+
minl = self._sharex.xaxis.get_minor_locator()
858861

859-
# This overwrites the current formatter
862+
# This overwrites the current formatter/locator
860863
self.xaxis.set_scale(self._sharex.xaxis.get_scale())
861864

862-
# Reset the formatter
863-
self.xaxis.set_major_formatter(frmt)
865+
# Reset the formatter/locator
866+
self.xaxis.set_major_formatter(majf)
867+
self.xaxis.set_minor_formatter(minf)
868+
self.xaxis.set_major_locator(majl)
869+
self.xaxis.set_minor_locator(minl)
864870
else:
865871
self.xaxis.set_scale('linear')
866872

@@ -870,14 +876,20 @@ def cla(self):
870876
y0, y1 = self._sharey.get_ylim()
871877
self.set_ylim(y0, y1, emit=False, auto=None)
872878

873-
# Save the current formatter so we don't lose it
874-
frmt = self._sharey.yaxis.get_major_formatter()
879+
# Save the current formatter/locator so we don't lose it
880+
majf = self._sharey.yaxis.get_major_formatter()
881+
minf = self._sharey.yaxis.get_minor_formatter()
882+
majl = self._sharey.yaxis.get_major_locator()
883+
minl = self._sharey.yaxis.get_minor_locator()
875884

876-
# This overwrites the current formatter
885+
# This overwrites the current formatter/locator
877886
self.yaxis.set_scale(self._sharey.yaxis.get_scale())
878887

879-
# Reset the formatter
880-
self.yaxis.set_major_formatter(frmt)
888+
# Reset the formatter/locator
889+
self.yaxis.set_major_formatter(majf)
890+
self.yaxis.set_minor_formatter(minf)
891+
self.yaxis.set_major_locator(majl)
892+
self.yaxis.set_minor_locator(minl)
881893
else:
882894
self.yaxis.set_scale('linear')
883895

0 commit comments

Comments
 (0)