'Python/Matplotlib'에 해당되는 글 2건

  1. 2020.10.21 matplotlib에서 figure창을 자동으로 닫기
  2. 2020.10.21 matplotlib으로 figure창을 여러개 띄우기

파이참으로 파이썬 코드 실행 중, figure을 여러개 띄울 때, 창을 닫아야만 그 다음 코드로 진행이 되었다. 이것이 불편해 창을 자동으로 닫게 할 수 있었다. 
plt.show(block=False)

plt.pause(1)

plt.close()

 

src: stackoverflow.com/questions/40395659/view-and-then-close-the-figure-automatically-in-matplotlib

 

이렇게 하면 창이 1초 후 닫히게 된다.

 

 

 

 
 
 

'Python > Matplotlib' 카테고리의 다른 글

matplotlib으로 figure창을 여러개 띄우기  (0) 2020.10.21
Posted by uniqueone
,

파이참으로 파이썬 코드 실행 중, figure을 여러개 띄울 때, 창을 닫아야만 그 다음 코드로 진행이 되었다. 이것이 불편해 찾아보니 

import matplotlib.pyplot as plt

x=[[1,2,3,4],[1,2,3,4],[1,2,3,4],[1,2,3,4]]

y=[[1,2,3,4],[1,2,3,4],[1,2,3,4],[1,2,3,4]]

for i in range(len(x)):

    plt.figure()

    plt.plot(x[i],y[i])

    # Show/save figure as desired.

    #plt.show()

# Can show all four figures at once by calling plt.show() here, outside the loop.

plt.show()

src: stackoverflow.com/questions/19189488/use-a-loop-to-plot-n-charts-python

에서처럼 그리고자 하는 그림들을 plt.figure() plt.plot(x)으로 각각 그려준 뒤, 맨 마지막에 plt.show()를 1번만 호출하면 전체창이 한꺼번에 띄어졌다.

 

import matplotlib.pyplot as plt

x=[[1,2,3,4],[1,2,3,4],[1,2,3,4],[1,2,3,4]]

y=[[1,2,3,4],[1,2,3,4],[1,2,3,4],[1,2,3,4]]

for i in range(len(x)):

    plt.figure()

    plt.plot(x[i],y[i])

    # Show/save figure as desired.

    plt.show()

# Can show all four figures at once by calling plt.show() here, outside the loop.

#plt.show()

처럼 하면 창을 매번 닫아야 그 다음이 진행된다.

 

 

 

 
 
 
 

'Python > Matplotlib' 카테고리의 다른 글

matplotlib에서 figure창을 자동으로 닫기  (0) 2020.10.21
Posted by uniqueone
,