【发布时间】:2020-04-29 18:12:57
【问题描述】:
我希望在 Python 3 中从包含能量原始数据 (.dat) 的输入文件制作直方图。在同一个图上,我想绘制一个公式(分布分析,pho 与能量)。单独绘制它们很容易,但我需要组合版本。你能帮忙吗?
【问题讨论】:
-
你试过
matplotlib.pyplot.subplot吗?
我希望在 Python 3 中从包含能量原始数据 (.dat) 的输入文件制作直方图。在同一个图上,我想绘制一个公式(分布分析,pho 与能量)。单独绘制它们很容易,但我需要组合版本。你能帮忙吗?
【问题讨论】:
matplotlib.pyplot.subplot 吗?
如果您想在同一个图中有 2 个图,请查看以下内容: https://matplotlib.org/3.1.0/gallery/subplots_axes_and_figures/subplots_demo.html
fig, (ax1, ax2) = plt.subplots(2)
如果您想在共享轴的同一图中有 2 个图,请使用: https://matplotlib.org/3.1.0/gallery/subplots_axes_and_figures/two_scales.html#sphx-glr-gallery-subplots-axes-and-figures-two-scales-py
ax2 = ax1.twinx() # instantiate a second axes that shares the same x-axis
【讨论】: