我的代码
import matplotlib.pyplot as plt
plt.style.use("ggplot")
import numpy as np
from mtspec import mtspec
from mtspec.util import _load_mtdata
data = np.loadtxt('262_V01_C00_R000_TEx_BL_4096H.dat')
spec,freq,jackknife,f_statistics,degrees_of_f = mtspec(data=data, delta= 4930.0, time_bandwidth=4 ,number_of_tapers=5, nfft= 4194304, statistics=True)
fig = plt.figure()
ax2 = fig
ax2.plot(freq, spec, color='black')
ax2.fill_between(freq, jackknife[:, 0], jackknife[:, 1],color="red", alpha=0.3)
ax2.set_xlim(freq[0], freq[-1])
ax2.set_ylim(0.1E1, 1E5)
ax2.set_xlabel("Frequency $")
ax2.set_ylabel("Power Spectral Density $)")
plt.tight_layout()
plt.show()
问题是我的代码的绘图部分。我应该更改什么?我在Ubuntu上使用Python 2.7。
将
ax2
分配给一个figure
对象,该对象没有定义plot
方法。你想用plt.axes
来创建轴而不是用以下方式调用图:
尝试使用
gca()
提取轴:相关问题 更多 >
编程相关推荐