多外形演示

使用多个图形窗口和子图形。

  1. import matplotlib.pyplot as plt
  2. import numpy as np
  3. t = np.arange(0.0, 2.0, 0.01)
  4. s1 = np.sin(2*np.pi*t)
  5. s2 = np.sin(4*np.pi*t)

Create figure 1

  1. plt.figure(1)
  2. plt.subplot(211)
  3. plt.plot(t, s1)
  4. plt.subplot(212)
  5. plt.plot(t, 2*s1)

多外形演示

Create figure 2

  1. plt.figure(2)
  2. plt.plot(t, s2)

多外形演示2

Now switch back to figure 1 and make some changes

  1. plt.figure(1)
  2. plt.subplot(211)
  3. plt.plot(t, s2, 's')
  4. ax = plt.gca()
  5. ax.set_xticklabels([])
  6. plt.show()

多外形演示3

下载这个示例