Python:使用 "class" 生成的图创建子图

Python: Create subplots with plots generated by a "class"

我知道我想做什么,但我不知道如何提出这个问题。

在我的代码中,我使用了 lightkurve 包,它有一个 class (lightkurve.lightcurve.TessLightCurve)它有一个绘制变量内容的方法(plot)。 “绘图”方法使用matplotlib。

通过这种方式,我可以绘制两个独立的图形,如下所示:

curve.plot()
plt.title("Merged unnormalized light curve \n nº of sectors merged: {0}".format(len(tpfs)))

corrected_curve.plot()
plt.title("Merged NORMALIZED light curve \n nº of sectors merged: {0}".format(len(tpfs)))

那就给我下面的数字:

我想要做的是将这两个数字作为子图绘制成一个图。 我知道如何使用 matplotlib page 中描述的典型图和子图来做到这一点,但我不知道如何使用这种类型的数字来做到这一点 :(

看起来像函数 lightkurve.lightcurve.TessLightCurve.plot() takes an argument ax= 指示使用哪个子图。

fig, (ax1, ax2) = plt.subplots(nrows=2, ncols=1)
curve.plot(ax=ax1)
ax1.set_title("Merged unnormalized light curve \n nº of sectors merged: {0}".format(len(tpfs)))

corrected_curve.plot(ax=ax2)
ax2.set_title("Merged NORMALIZED light curve \n nº of sectors merged: {0}".format(len(tpfs)))