[英]matplotlib. How do I switch between subplots, rather than replotting them from scratch?
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. 随着新数据的到来,我想在给定的子图上绘制它。
How 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
然后你可以通过引用
plt1
和plt2
绘制线条和点以及你想要的任何其他plt2
Take a look at the reference for everything you can do with the plot. 看看你可以用情节做的所有事情的参考 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.