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 6992c8f

Browse filesBrowse files
committed
Don't hide shared "x/y"ticklabels for grids of non-rectilinear axes.
In particular, hiding the "x/y" (i.e. theta/r) ticklabels doesn't make sense for polar axes, and I'd guess likewise for most projections other than the default rectilinear. Try e.g. `subplots(2, 2, subplot_kw=dict(projection="polar"), sharex=True, sharey=True)`.
1 parent 0c84324 commit 6992c8f
Copy full SHA for 6992c8f

File tree

Expand file treeCollapse file tree

2 files changed

+14
-6
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+14
-6
lines changed

‎lib/matplotlib/gridspec.py

Copy file name to clipboardExpand all lines: lib/matplotlib/gridspec.py
+7-6Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -308,12 +308,13 @@ def subplots(self, *, sharex=False, sharey=False, squeeze=True,
308308
self[row, col], **subplot_kw)
309309

310310
# turn off redundant tick labeling
311-
if sharex in ["col", "all"]:
312-
for ax in axarr.flat:
313-
ax._label_outer_xaxis()
314-
if sharey in ["row", "all"]:
315-
for ax in axarr.flat:
316-
ax._label_outer_yaxis()
311+
if all(ax.name == "rectilinear" for ax in axarr.flat):
312+
if sharex in ["col", "all"]:
313+
for ax in axarr.flat:
314+
ax._label_outer_xaxis()
315+
if sharey in ["row", "all"]:
316+
for ax in axarr.flat:
317+
ax._label_outer_yaxis()
317318

318319
if squeeze:
319320
# Discarding unneeded dimensions that equal 1. If we only have one

‎lib/matplotlib/tests/test_polar.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_polar.py
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,3 +357,10 @@ def test_thetalim_args():
357357
assert tuple(np.radians((ax.get_thetamin(), ax.get_thetamax()))) == (0, 1)
358358
ax.set_thetalim((2, 3))
359359
assert tuple(np.radians((ax.get_thetamin(), ax.get_thetamax()))) == (2, 3)
360+
361+
362+
def test_shared_polar_keeps_ticklabels():
363+
_, axs = plt.subplots(
364+
2, 2, subplot_kw=dict(projection="polar"), sharex=True, sharey=True)
365+
assert axs[0, 1].xaxis._major_tick_kw["label1On"]
366+
assert axs[0, 1].yaxis._major_tick_kw["label1On"]

0 commit comments

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