将两个图形合并为一个而无需绘制

时间:2019-11-23 07:48:13

标签: python matplotlib

我正在努力合并两个类别为matplotlib.figure.Figure的图形。

我使用api来获取对象,所以我没有要绘制的数据。

典型的合并图形解决方案使用plt.subplots作为显式绘制数据的方式,

import numpy as np
from matplotlib.pyplot import figure, show


x = [val*np.pi/2 for val in np.arange(0, 15, 0.01)]

fig = figure()
fig.subplots_adjust(hspace=0.3)

ax = fig.add_subplot(211)
line1, = ax.plot(x, np.cos(x))

ax = fig.add_subplot(212)
line2, = ax.plot(x, np.cos(x))

而我只有两个对象,例如matplotlib.figure.Figure,没有要绘制的东西。

print(type(figure_top))
print(type(figure_bottom))

# <class 'matplotlib.figure.Figure'>
# <class 'matplotlib.figure.Figure'>

在这种情况下,合并两个图形的最佳方法是什么?

0 个答案:

没有答案