【发布时间】:2021-12-20 17:11:33
【问题描述】:
我试图将三个“双峰/二元直方图”放在同一个图上,标记为实际值而不是 bin。不确定这是否有意义...但是,我想显示每个向量 x1、x2 和 x3 中仅有的 2 个值。
代码如下:
import matplotlib.pyplot as plt
x1 = [0.003996747444034554, 0.003996747444034554, 0.003996747458586469, 0.003996747444034554, 0.003996747444034554, 0.003996747444034554, 0.003996747458586469, 0.003996747444034554, 0.003996747444034554, 0.003996747444034554]
x2 = [0.003996536252088845, 0.003996536252088845, 0.003996536252088845, 0.003996536310296506, 0.003996536252088845, 0.003996536252088845, 0.003996536252088845, 0.003996536252088845, 0.003996536252088845, 0.003996536252088845]
x3 = [0.003996643703430891, 0.003996643703430891, 0.003996643703430891, 0.003996643703430891, 0.003996643703430891, 0.003996643761638552, 0.003996643703430891, 0.003996643703430891, 0.003996643703430891, 0.003996643703430891]
fig, axs = plt.subplots(1,3, figsize=([7,4]), sharey = True)
axs[0].hist(x1)
axs[1].hist(x2)
axs[2].hist(x3)
plt.tight_layout()
plt.figure(figsize=([7,4]))
plt.hist([x1,x2,x3])
【问题讨论】:
-
您的 3 个数组不相交,我不知道如何修改您的绘图。
标签: python matplotlib bar-chart histogram