Skip to content

Commit f32cfc5

Browse files
QuLogicmeeseeksmachine
authored andcommitted
Backport PR matplotlib#31594: DOC: Explain how to selectively restore ticks that are removed by sharex
1 parent d65eee8 commit f32cfc5

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

galleries/examples/subplots_axes_and_figures/subplots_demo.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,18 @@
141141
# %%
142142
# For subplots that are sharing axes one set of tick labels is enough. Tick
143143
# labels of inner Axes are automatically removed by *sharex* and *sharey*.
144-
# Still there remains an unused empty space between the subplots.
145-
#
144+
# You can selectively restore them using `~.axes.Axes.tick_params`.
145+
146+
fig, axs = plt.subplots(3, sharex=True, sharey=True)
147+
fig.suptitle('Restored xtick labels on to Axes')
148+
axs[0].plot(x, y ** 2)
149+
axs[1].plot(x, 0.3 * y, 'o')
150+
axs[2].plot(x, y, '+')
151+
152+
axs[0].tick_params(labelbottom=True)
153+
154+
# %%
155+
# It is also possible to remove the empty space between the subplots.
146156
# To precisely control the positioning of the subplots, one can explicitly
147157
# create a `.GridSpec` with `.Figure.add_gridspec`, and then call its
148158
# `~.GridSpecBase.subplots` method. For example, we can reduce the height

0 commit comments

Comments
 (0)