【问题标题】:How Can I Turn my Line Plot into a Histogram?我怎样才能把我的线图变成直方图?
【发布时间】:2021-11-01 20:38:49
【问题描述】:

我对 Python 非常陌生,我正在尝试创建一个直方图,比较 4 个传感器在一天内收集的温度。我已经对数据进行了分箱,并且能够创建折线图,但是在制作等效直方图时遇到了很多麻烦。

我的代码在下面,下面的每个“jun20BHX”都是我通过从一些包含所有临时数据的 CSV 中逐小时获取平均温度而制作的 ndarray。

plt.plot(jun20BH1[:,1],jun20BH1[:,2], label = 'Full Shade', linewidth = 4, linestyle='solid')
plt.plot(jun20BH2[:,1],jun20BH2[:,2], label = 'Full Sun',linewidth = 4)
plt.plot(jun20BH3[:,1],jun20BH3[:,2], label = 'Partial Sun #1', linewidth = 4)
plt.plot(jun20BH4[:,1],jun20BH4[:,2], label = 'Partial Sun #2', linewidth = 4)

plt.xlabel("Hour of Day", fontsize = 24)
plt.ylabel("Temperature (F)", fontsize = 24)
plt.xticks(fontsize = 20)
plt.yticks(fontsize = 20)
plt.legend(fontsize = 20)
plt.title("June 20 Boerum Hill", fontsize = 50)

plt.show()```

Any help would be greatly appreciated!!!!

【问题讨论】:

    标签: python plot histogram


    【解决方案1】:

    你可以像这样在 numpy 中尝试 hist:

    ax.hist(data,bins=100,range=(minimum,maximum),facecolor="r", histtype = 'step')
    

    查看numpy plot and hist了解更多详情。

    【讨论】:

      猜你喜欢
      • 2014-01-28
      • 2020-11-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-03-26
      • 1970-01-01
      • 2010-11-04
      • 1970-01-01
      相关资源
      最近更新 更多