Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions lib/matplotlib/gridspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,12 +308,13 @@ def subplots(self, *, sharex=False, sharey=False, squeeze=True,
self[row, col], **subplot_kw)

# turn off redundant tick labeling
if sharex in ["col", "all"]:
for ax in axarr.flat:
ax._label_outer_xaxis()
if sharey in ["row", "all"]:
for ax in axarr.flat:
ax._label_outer_yaxis()
if all(ax.name == "rectilinear" for ax in axarr.flat):
if sharex in ["col", "all"]:
for ax in axarr.flat:
ax._label_outer_xaxis()
if sharey in ["row", "all"]:
for ax in axarr.flat:
ax._label_outer_yaxis()

if squeeze:
# Discarding unneeded dimensions that equal 1. If we only have one
Expand Down
7 changes: 7 additions & 0 deletions lib/matplotlib/tests/test_polar.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,3 +394,10 @@ def test_remove_shared_polar(fig_ref, fig_test):
2, 2, sharey=True, subplot_kw={"projection": "polar"})
for i in [0, 1, 3]:
axs.flat[i].remove()


def test_shared_polar_keeps_ticklabels():
_, axs = plt.subplots(
2, 2, subplot_kw=dict(projection="polar"), sharex=True, sharey=True)
assert axs[0, 1].xaxis._major_tick_kw["label1On"]
assert axs[0, 1].yaxis._major_tick_kw["label1On"]