【发布时间】:2021-02-10 03:26:56
【问题描述】:
说在可视化数据的过程中,我后来决定将两个现有的图合并在一个子图中进行大量注释,以便在同一个窗口中并排比较它们。
是的,我可以首先在子图中返回并重新创建这些。但是,有没有办法我可以抓住轴或图形手柄——我不明白它是如何工作的——无论是捕获单个图形的所有内容并使用数据来创建新的子图吗?
类似的东西
from numpy.random import seed
from numpy.random import randint
import matplotlib.pyplot as plt
x=list(range(1,11))
seed(1)
y1= randint(5, 35, 10)
seed(2)
y2= randint(5, 35, 10)
seed(3)
y3=randint(5, 35, 10)
fig1=plt.figure(1)
ax1=plt.plot(x,y1,x,y2,x,y3)
plt.xlabel('Xaxis')
plt.ylabel('yaxis')
plt.title('Some Plot')
plt.text(10,10, 'some text')
fig2=plt.figure(2)
ax2= plt.plot(x,y1+y2+y3)
# later, I say decided I wanted to also display the two plots as subplots in the same window.
fig3=pltfigure(3)
plt.subplot(2,1,1)
plt.plot(ax1) # plt.plot(fig1.lines),plt.plot(fig1)
plt.subplot(2,1,2)
plt.plot(ax2)
我正在寻找一种简单的方法来获取图 1 和图 2 中已经绘制的所有内容,并将其直接传递给图 3 中的子图。
【问题讨论】:
标签: matplotlib subplot