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

Appearance settings

Commit 63ff403

Browse filesBrowse files
committed
Fix locator/formatter setting when removing shared Axes
1 parent 76db501 commit 63ff403
Copy full SHA for 63ff403

File tree

Expand file treeCollapse file tree

2 files changed

+19
-5
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+19
-5
lines changed

‎lib/matplotlib/axis.py

Copy file name to clipboardExpand all lines: lib/matplotlib/axis.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1616,7 +1616,7 @@ def set_major_formatter(self, formatter):
16161616
"""
16171617
if not isinstance(formatter, mticker.Formatter):
16181618
raise TypeError("formatter argument should be instance of "
1619-
"matplotlib.ticker.Formatter")
1619+
"matplotlib.ticker.Formatter")
16201620
self.isDefault_majfmt = False
16211621
self.major.formatter = formatter
16221622
formatter.set_axis(self)

‎lib/matplotlib/figure.py

Copy file name to clipboardExpand all lines: lib/matplotlib/figure.py
+18-4Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1592,10 +1592,24 @@ def subplots(self, nrows=1, ncols=1, sharex=False, sharey=False,
15921592

15931593
def _remove_ax(self, ax):
15941594
def _reset_loc_form(axis):
1595-
axis.set_major_formatter(axis.get_major_formatter())
1596-
axis.set_major_locator(axis.get_major_locator())
1597-
axis.set_minor_formatter(axis.get_minor_formatter())
1598-
axis.set_minor_locator(axis.get_minor_locator())
1595+
# Set the formatters and locators to be associated with axis
1596+
# (where previously they may have been associated with another
1597+
# Axis isntance)
1598+
majfmt = axis.get_major_formatter()
1599+
if not majfmt.axis.isDefault_majfmt:
1600+
axis.set_major_formatter(majfmt)
1601+
1602+
majloc = axis.get_major_locator()
1603+
if not majloc.axis.isDefault_majloc:
1604+
axis.set_major_locator(majloc)
1605+
1606+
minfmt = axis.get_minor_formatter()
1607+
if not minfmt.axis.isDefault_minfmt:
1608+
axis.set_minor_formatter(minfmt)
1609+
1610+
minloc = axis.get_minor_locator()
1611+
if not minfmt.axis.isDefault_minloc:
1612+
axis.set_minor_locator(minloc)
15991613

16001614
def _break_share_link(ax, grouper):
16011615
siblings = grouper.get_siblings(ax)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.