在可视化数据的过程中,我后来决定合并两个在子图中带有大量注释的现有图,以在同一窗口中并排比较它们。
是的,我可以返回并首先在子图中重新创建它们。但是,有什么方法可以抓住轴或图形手柄吗?我不了解它们的工作原理,无论如何捕获单个图形的所有内容并使用创建新子图的数据?
类似于
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的子图。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句