Python 使用MatPlotLib绘制16000个数据点与时间的对比图

Python 使用MatPlotLib绘制16000个数据点与时间的对比图,python,matplotlib,graph,Python,Matplotlib,Graph,我试图绘制一架无人机的高度与时间(X轴上的时间和Y轴上的高度)。我使用dates=MatPlotLib.dates.date2num(时间戳)将时间戳列表转换为MatPlotLib可读格式。高度列表和转换的时间戳列表的长度正好是16587,因此不存在不匹配。这张图表非常可怕,我想知道如何用这么多的数据让它可读。我的全部代码是 timestamps = [] for stamp in times: #convert list of timestamp Strings to Python time

我试图绘制一架无人机的高度与时间(X轴上的时间和Y轴上的高度)。我使用
dates=MatPlotLib.dates.date2num(时间戳)
将时间戳列表转换为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()

即使不清楚您的期望是什么,图表也确实无法阅读

当绘制大量点时,我想最好还指定
alpha
参数,以增加透明度和重叠点的“透明”云

然后您可以指定
x
yticks
(也可以使用
rotation
参数)以显示它们的较小部分,并添加
plt.grid(True)


这些只是基本的建议。尽量在“使其可读”中更具体一些。

我想你对点没问题,但对记号标签没问题?你忘了将高度转换为数字。是的,X轴的时间很好,但它们重叠。我的高度是浮动的,这行吗?哦,我没有更改列表!!!这解决了很多问题,谢谢@ImportanceOfBeingErnest