Matplotlib.pyplot.savefig를 했을 때 빈화면으로 저장될때가 있다. 이럴때 는 순서의 문제이다. 아래의 예를 봐보자.
1. 잘못된 순서로 실행했을 때
<figure size 432x288 with 0 axes> 라고 뜨고, 아래와 같이 빈화면으로 저장된다.
2. 해결법
plt.savefig를 plt.show보다 앞에 적어주자.
이렇게 순서를 바꾸어주면 잘 저장됨을 알 수 있다.
참고자료 : 스택오버플로우
https://stackoverflow.com/questions/9012487/matplotlib-pyplot-savefig-outputs-blank-image
Matplotlib (pyplot) savefig outputs blank image
I am trying to save plots I make using matplotlib; however, the images are saving blank. Here is my code: plt.subplot(121) plt.imshow(dataStack, cmap=mpl.cm.bone) plt.subplot(122) y = copy.deepc...
stackoverflow.com
'matplotlib&seaborn' 카테고리의 다른 글
matplotlib 으로 histogram을 그려보자! (0) | 2021.11.30 |
---|---|
%matplotlib inline , UsageError: unrecognized arguments 해결하기! (0) | 2021.11.28 |
matplotlib.pyplot.pie : pie차트, 퍼센트를 차트로 원형차트를 그려보자! (0) | 2021.11.28 |
matplotlib.pyplot.countplot : Categorical Data의 값(values)의 개수를 카운트해서 그래프로! (0) | 2021.11.28 |
matplotlib.pyplot 가장 기본적인 plot : line chart, line plot (0) | 2021.11.28 |