반응형
배열에 저장된 3 개의 히스토그램을 업데이트하는 복잡한 알고리즘이 있습니다. 알고리즘을 디버깅하고 싶기 때문에 사용자 인터페이스에서 배열을 히스토그램으로 표시 할 생각이었습니다. 이를 수행하는 가장 쉬운 방법은 무엇입니까? (최적화 된 코드보다 신속한 애플리케이션 개발이 더 중요합니다.)
Qt (C ++)에 대한 경험과 matplotlib에 대한 경험이 있습니다.
(이 질문을 하루나 이틀 동안 열어 두겠습니다. 내가 가지고 있지 않은 경험이 많지 않으면 솔루션을 평가하기가 어렵 기 때문입니다. 커뮤니티의 투표가 최선의 답변을 선택하는 데 도움이되기를 바랍니다.)
해결 방법
편집 : 요즘에는 matplotlib.animation
을 사용하는 것이 더 쉽고 좋습니다.
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
def animate(frameno):
x = mu + sigma * np.random.randn(10000)
n, _ = np.histogram(x, bins, normed=True)
for rect, h in zip(patches, n):
rect.set_height(h)
return patches
mu, sigma = 100, 15
fig, ax = plt.subplots()
x = mu + sigma * np.random.randn(10000)
n, bins, patches = plt.hist(x, 50, normed=1, facecolor='green', alpha=0.75)
ani = animation.FuncAnimation(fig, animate, blit=True, interval=10,
repeat=True)
plt.show()
import numpy as np
import matplotlib.pyplot as plt
plt.ion()
mu, sigma = 100, 15
fig = plt.figure()
x = mu + sigma*np.random.randn(10000)
n, bins, patches = plt.hist(x, 50, normed=1, facecolor='green', alpha=0.75)
for i in range(50):
x = mu + sigma*np.random.randn(10000)
n, bins = np.histogram(x, bins, normed=True)
for rect,h in zip(patches,n):
rect.set_height(h)
fig.canvas.draw()
참조 페이지 https://stackoverflow.com/questions/4129697
반응형
'파이썬' 카테고리의 다른 글
파이썬 JSONDecodeError : ','구분 기호 예상 : 줄 1 열 43 (문자 42) (0) | 2020.10.25 |
---|---|
파이썬 Django 양식의 읽기 전용 필드 (0) | 2020.10.25 |
파이썬 How to increment datetime by custom months in python without using library (0) | 2020.10.25 |
파이썬 문자열을 사용하여 Python에서 함수 호출 (0) | 2020.10.25 |
파이썬 PIL을 설치하려고 할 때 오류 발생 (0) | 2020.10.25 |
댓글