开发者

matplotlib. How do I switch between subplots, rather than replotting them from scratch?

开发者 https://www.devze.com 2023-01-06 16:40 出处:网络
I create a figure and fill it with a couple of subplots. As new data arrives, I\'d like to draw it on a given subplot.

I create a figure and fill it with a couple of subplots.

As new data arrives, I'd like to draw it on a given subplot.

H开发者_运维知识库ow do I switch between subplots so that I don't have to create new subplot objects each time?

Example:

from matplotlib.pyplot import figure,

figure()
subplot(2,1,1)
subplot(2,1,2)

# now go back and plot something on subplot 1 ...?


Assign subplot to a variable:

fig = matplotlib.pyplot.figure()

plt1 = fig.add_subplot(2,1,1)
plt2 = fig.add_subplot(2,1,2)

Then you can draw lines and points and whatever else you want with references to plt1 and plt2

Take a look at the reference for everything you can do with the plot.

0

精彩评论

暂无评论...
验证码 换一张
取 消