我有一个数据集,我想在其中绘制每个深度测量次数的直方图。我想绘制深度列中每个测量频率的直方图。我想将数据从 0m 开始分成 5m 块,一直到 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) …Run Code Online (Sandbox Code Playgroud) 我有一个由多个温度曲线组成的数据集,我想创建一个平均温度曲线.为了做到这一点,我想如果我可以计算每个深度的平均值,那么我可以简单地绘制图上每个深度的平均温度.
我知道为了计算深度的平均温度,我可以使用:
import numpy as np
import datetime as dt
import matplotlib.pyplot as plt
#read in data here
temper2out = []
temperature2m = np.mean(temperature[depth==2])
temper2out.extend(list(temperature2m)
T2out = np.array(temper2out)
t2 = np.mean(T2out)
tout.extend(list(t2)) #I could then do this for every depth, but since it goes to 150m, that would be lengthy.
Tout = np.array(tout)
Run Code Online (Sandbox Code Playgroud)
我知道这可以给我一些结果,但这是一个冗长的方式来做到这一点.我也不知道如何绘制这个.所以我的问题是,有没有更好的方法来解决这个问题?如果是这样,怎么样?很抱歉这么多,我对Python很新!
数据采用这种格式(抱歉,我不知道如何获取pastebin):
TagID ProfileNo ProfileDirn DateTime Lat Lon Depth Temperature
pv42-156-12 1 A 25/01/2012 00:00 52.90618 0.36051 2 5.04
pv42-156-12 1 A 25/01/2012 00:00 52.90618 0.36051 3 …Run Code Online (Sandbox Code Playgroud)