두 개의 하위 플롯이 있는데, 두 개는 비디오 피드의 프레임을 표시하고 세 번째는 계산 결과를 막대 그래프로 표시합니다. matplotlib 그림을 만든 후 몇 가지 subplot2grid를 만든 다음 FuncAnimation으로 업데이트합니다. 나는 (업데이트 예정) 막대 그래프를 만들 것subplot2grid의 막대 그래프
일반적인 방법은 다음과 같습니다
fig = plt.figure()
ax = plt.axes(xlim=(0, 9), ylim=(0, 100))
rects = plt.bar(res_x, res_y, color='b')
def animate(args):
...
...
for rect, yi in zip(rects, results):
rect.set_height(yi*100)
return rects
anim = animation.FuncAnimation(fig, animate, frames=200, interval=20, blit=True)
plt.show()
지금은 측면을 따라 막대 그래프 다른 줄거리 추가하려고
:
fig = plt.figure()
plt1 = plt.subplot2grid((2, 2), (0, 0), rowspan=2)
plt2 = plt.subplot2grid((2, 2), (0, 1))
#Confusion with the following
bar_plot = plt.subplot2grid((2,2), (1,1))
ax = plt.axes(xlim=(0, 9), ylim=(0, 100))
rects = plt.bar(res_x, res_y, color='b')
def animate(args):
...
...
im1 = plt1.imshow(...)
im2 = plt2.imshow(...)
for rect, yi in zip(rects, results):
rect.set_height(yi*100)
return im1, im2, rects
anim = animation.FuncAnimation(fig, animate, frames=200, interval=20, blit=True)
plt.show()
I을 다음과 같은 오류를 얻을 : AttributeError를 'BarContainer'개체가
어떤 아이디어 'set_animated'에는 속성이없는 내가 어떻게 할 수있는 "장소"는 부가 적 줄거리로 막대 그래프, 그리고 다른 데이터 FR과 함께 업데이트해야 om subplots?
감사합니다.
@dtam, 당신은 [승인] 고려해야한다 (https://meta.stackexchange.com/questions/5234/how-does 대답하는 일). 그렇지 않은 경우 질문을 업데이트하여 자세한 내용을 제공 할 수 있습니다. 대답이 도움이된다면 상향 투표를 고려할 수도 있습니다 (문제가 해결된다면 아마도 그럴 것입니다). 물론, 이전 질문 ([여기] (http://stackoverflow.com/questions/43099734/combining-cv2-imshow-with-matplotlib-plt-show-in-real-time)과 [여기 ] (http://stackoverflow.com/questions/43372792/matplotlib-opencv-image-subplot)). – ImportanceOfBeingErnest
이 솔루션을 사용하면 다음 오류가 표시됩니다. "AttributeError : draw_artist는 렌더링을 캐시하는 초기 그리기 후에 만 사용할 수 있습니다." 또한 막대 그래프의 플롯이 열리지 만 다른 두 서브 플롯은 포함되지만 세 명 모두 하위 계보가되고 함께 모이기를 원합니다. 어떤 생각? 나는 이전의 것을 받아들이지 않는 것에 대해 사과합니다. 나는 지금 그들에게 연락 할 것입니다. – dtam
전체 코드를 표시하지 않으므로이 오류의 출처를 알 수 없습니다. 하지만 나는 내 대답에 [mcve]를 추가하여 예상대로 작동 함을 보여줍니다. – ImportanceOfBeingErnest