为了账号安全,请及时绑定邮箱和手机立即绑定

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

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

慕村9548890 2024-01-15 15:18:32
我知道我想做什么,但我不知道如何提出这个问题。在我的代码中,我使用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)))这给了我以下数字:我想做的是用这两个数字作为子图绘制一个图。我知道如何使用典型的图和子图(如matplotlib 页面中描述的图和子图)来完成此操作,但我不知道如何使用这种类型的数字来完成此操作:(
查看完整描述

1 回答

?
阿晨1998

TA贡献2037条经验 获得超6个赞

看起来该函数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)))



查看完整回答
反对 回复 2024-01-15
  • 1 回答
  • 0 关注
  • 33 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信