<jupyter_start><jupyter_text>Creating adjacent subplotsTo create plots that share a common axis (visually) you can set the hspacebetween the subplots to zero. Passing sharex=True when creating the subplotswill automatically turn off all x ticks and labels except those on the bottomaxis.In this example the plots share a common x axis but you can follow the samelogic to supply a common y axis.<jupyter_code>import matplotlib.pyplot as plt
import numpy as np

t = np.arange(0.0, 2.0, 0.01)

s1 = np.sin(2 * np.pi * t)
s2 = np.exp(-t)
s3 = s1 * s2

fig, axs = plt.subplots(3, 1, sharex=True)
# Remove horizontal space between axes
fig.subplots_adjust(hspace=0)

# Plot each graph, and manually set the y tick values
axs[0].plot(t, s1)
axs[0].set_yticks(np.arange(-0.9, 1.0, 0.4))
axs[0].set_ylim(-1, 1)

axs[1].plot(t, s2)
axs[1].set_yticks(np.arange(0.1, 1.0, 0.2))
axs[1].set_ylim(0, 1)

axs[2].plot(t, s3)
axs[2].set_yticks(np.arange(-0.9, 1.0, 0.4))
axs[2].set_ylim(-1, 1)

plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13470993117010815, 'fraction_numerical': 0.051130776794493606, 'mean_word_length': 4.655555555555556, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '205479', 'license': 'MIT', 'n_tokens_mistral': 442, 'n_tokens_neox': 419, 'n_words': 123, 'path': 'matplotlib/gallery_jupyter/subplots_axes_and_figures/ganged_plots.ipynb', 'repo_name': 'kingreatwill/penter', 'size': '1017'}