使用for循环生成直方图

2024-06-25 06:52:00 发布

您现在位置:Python中文网/ 问答频道 /正文

当我试图在for循环中获取直方图时,我似乎遇到了一个问题。我的代码如下:

for i in channel_list:

    ch = int(i)
    channel_data = buf.getChannelData(ch)
    time_seq = buf.getTimeSequence(0.0)


    #specify the parameters here:

    aveChannel_data = np.mean(channel_data[0:100])
    calChannel_data = channel_data - aveChannel_data


    channel, up, low, mid, before, after= self.drop_time(ch,calChannel_data)
    fall_time = time_seq[low]- time_seq[before]
    rise_time = time_seq[after] - time_seq[low]

    plt.hist(fall_time, bins = 30)

histogram I want

但我得到的结果是:

results I am getting

似乎每一次迭代,新数据都会被绘制在旧数据上。在

有什么办法解决这个问题吗?在


Tags: 数据fordatatimechannelch直方图seq