반응형
내 코드
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()
문제는 내 코드의 플로팅 부분에 있습니다. 무엇을 변경해야합니까? 우분투에서 Python 2.7을 사용하고 있습니다.
해결 방법
plot
메서드가 정의되지 않은 figure
객체에 ax2
를 할당합니다. 대신 plt.axes
를 사용하여 축을 만들고 싶습니다.
ax2 = plt.axes()
# Instead of ax2 = fig
참조 페이지 https://stackoverflow.com/questions/38701137
반응형
'파이썬' 카테고리의 다른 글
파이썬 "from __future__ 가져 오기는 파일의 시작 부분에서 발생해야합니다": 파일의 시작을 정의하는 것은 무엇입니까? (0) | 2020.11.01 |
---|---|
파이썬 Python에서 환경 변수를 문자열로 평가하는 방법은 무엇입니까? (0) | 2020.11.01 |
파이썬 Windows에 Gensim을 설치하는 방법 (0) | 2020.11.01 |
파이썬 Django 오류 : render_to_response ()에 예기치 않은 키워드 인수 'context_instance'가 있습니다. (0) | 2020.11.01 |
파이썬 Jupyter 노트북은 두 개의 판다 테이블을 나란히 표시합니다. (0) | 2020.10.31 |
댓글