简体   繁体   English

如何将我的线图变成直方图?

[英]How Can I Turn my Line Plot into a Histogram?

I am very new to Python and I am trying to create a histogram comparing temperatures collected by 4 sensors in a single day.我对 Python 非常陌生,我正在尝试创建一个直方图,比较 4 个传感器在一天内收集的温度。 I have already binned my data and am able to create a line graph, but I'm having a lot of trouble making the equivalent histogram.我已经对我的数据进行了分箱,并且能够创建一个折线图,但是我在制作等效直方图时遇到了很多麻烦。

My code is below and each "jun20BHX" below is an ndarray I made by taking average temperatures hour by hour from some CSVs I have with all the temp data.我的代码在下面,下面的每个“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!!!!

You can try hist in numpy like this:您可以像这样在 numpy 中尝试 hist:

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

check this numpy plot and hist for more details.检查这个numpy plot 和 hist以获取更多详细信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM