我有一个数据集,想要绘制每个深度测量次数的直方图。我想要绘制深度列中测量频率的直方图。我想将数据分成5m一组,从0m开始到155m。这段代码可以得到一个直方图,形状看起来合理,但值似乎不对,而且我无法让它从0开始。此外,我希望能够交换x轴和y轴,使深度在y轴上,频率在x轴上。
import numpy as np
import datetime as dt
import matplotlib.pyplot as plt
import glob
#The data is read in, and then formatted so that an array Dout (based on depth) is created. This is done since multiple files will be read into the code, and so I can create the histogram for all the files I have up until this point.
Dout = np.array(depthout)
bins = np.linspace(0, 130, num=13) #, endpoint=True, retstep=False)
plt.hist(Dout, bins)
plt.xlabel('Depth / m')
plt.ylabel('Frequency')
plt.show()
# the end
数据格式如下:
TagID ProfileNo ProfileDirn DateTime Lat Lon Depth Temperature