希望使用MatPlotLib绘制16,000个数据点与时间的关系图

问题描述 投票:0回答:1

我正在尝试绘制无人机的高度与时间的关系(X轴上的时间和Y轴上的高度)。我使用dates = matplotlib.dates.date2num(timestamps)将时间戳列表转换为MatPlotLib可读格式。海拔列表和转换后的时间戳列表的长度恰好是16587,因此那里没有不匹配的情况。该图绝对可怕,我想知道如何用大量数据使它可读。我的完整代码是

timestamps = []

for stamp in times: #convert list of timestamp Strings to Python timestamp objects
    stamp = date + " " + stamp
    stamp = stamp.replace('.', ':') # We want the milliseconds to be behind a colon so it can be easily formatted to DateTime
    stamp = datetime.strptime(stamp, '%Y-%m-%d %H:%M:%S:%f')
    timestamps.append(stamp)

dates = matplotlib.dates.date2num(timestamps)

for alt in altitudes:
    alt = round(float(alt), 2)


plt.plot_date(dates, altitudes)

plt.show()

“丑图”

python matplotlib graph
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.