Python:使用“类”生成的图创建子图

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


在我的代码中,我使用lightkurve包,它有一个类(lightkurve.lightcurve.TessLightCurve),该类有一个绘制变量内容的方法(plot)。“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)))

这给了我以下数字:

https://img1.sycdn.imooc.com/65a4dc7e000100e306510617.jpg

我想做的是用这两个数字作为子图绘制一个图。我知道如何使用典型的图和子图(如matplotlib 页面中描述的图和子图)来完成此操作,但我不知道如何使用这种类型的数字来完成此操作:(



慕村9548890
浏览 35回答 1
1回答

阿晨1998

看起来该函数lightkurve.lightcurve.TessLightCurve.plot() 需要一个参数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)))
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python