首页 > 解决方案 > python,直方图,数据拟合

问题描述

我希望在 Python 3 中从包含能量原始数据 (.dat) 的输入文件制作直方图。在同一个图上,我想绘制一个公式(分布分析,pho 与能量)。单独绘制它们很容易,但我需要组合版本。你能帮我吗?

标签: pythonhistogram

解决方案


如果你想在同一个图中有 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 -双尺度-py

ax2 = ax1.twinx() # instantiate a second axes that shares the same x-axis


推荐阅读