如何使用我自己的值和频率在 python 中创建直方图而不使用 bin

how to create a histogram in python using my own values and frequencies witthout bins

如何使用我自己的频率在 python 上创建直方图,当我使用 bins 时,它会给我另一个值: 我在 0 和 1 之间有 1000 个数字,例如,我有 63 个数字在 [0, 0.05[ 但在直方图中我希望频率为 0.063 所有频率除以 1000

    Frequencies =[0.063,0.047,0.049,0.051,0.049,0.045,0.033,0.055,0.047,0.052,0.048,0.067,0.033,0.056,0.055,0.041,0.048,0.05,0.072,0.039]
   Intervals = [0 , 0.05 , 0.1 , 0.15 , 0.2 , 0.25 , 0.3 , 0.35 , 0.4 , 0.45 , 0.5 , 0.55 , 0.6 , 0.65 , 0.7, 0.75 ,0.8 , 0.85, 0.9 , 0.95, 1]

我需要绘制一个直方图,例如对于区间 [0, 0.05[,高度将为 0.063 我试过了

    plt.hist(Frequencies , bins = Intervals)

但是结果是错误的

您已经有了频率,所以您不需要 plt.hist,只需 plt.bar:

x = range(len(Frequencies))
plt.bar(x, Frequencies)
tick_labels = [f'[{Intervals[i]},{Intervals[i+1]}[' for i in range(len(Intervals)-1)]
plt.xticks(x, tick_labels, rotation='vertical')