【发布时间】:2014-10-09 14:09:08
【问题描述】:
我正在绘制几种共享 x 轴的数据类型,因此我使用 matplotlib.pylot subplots 命令
共享的 x 轴是时间(以公元年为单位)。我拥有的最后一个子图是独立观察的数量作为时间的函数。我有以下代码
import numpy as np
import matplotlib.pyplot as plt
#
# There's a bunch of data analysis here
#
f, ax = plt.subplots(4, sharex=True)
# Here I plot the first 3 subplots with no issue
x = np.arange(900, 2000, 1)#make x array in steps of 1
ax[3].plot(x[0:28], np.ones(len(x[0:28])),'k')#one observation from 900-927 AD
ax[3].plot(x[29:62], 2*np.ones(len(x[29:62])),'k')#two observations from 928-961 AD
现在,当我运行此代码时,我得到的子图只显示第二个 ax[3] 图,而不是第一个图。我怎样才能解决这个问题??谢谢
【问题讨论】:
标签: python numpy matplotlib subplot