1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
"""
===========================
Share axis limits and views
===========================
It's common to make two or more plots which share an axis, e.g., two subplots
with time as a common axis. When you pan and zoom around on one, you want the
other to move around with you. To facilitate this, matplotlib Axes support a
``sharex`` and ``sharey`` attribute. When you create a `~.pyplot.subplot` or
`~.pyplot.axes`, you can pass in a keyword indicating what Axes you want to
share with.
"""
import matplotlib.pyplot as plt
import numpy as np
t = np.arange(0, 10, 0.01)
ax1 = plt.subplot(211)
ax1.plot(t, np.sin(2*np.pi*t))
ax2 = plt.subplot(212, sharex=ax1)
ax2.plot(t, np.sin(4*np.pi*t))
plt.show()
# %%
# .. tags::
#
# component: axis
# plot-type: line
# level: beginner
|