简体   繁体   English

Matplotlib时间序列图轨迹问题

[英]Matplotlib Time Series Plot Trajectory Issue

I am trying to plot time series data to tell visually if there are any points that stand out as outliers. 我正在尝试绘制时间序列数据以直观地告诉我们是否有任何点与众不同。 I am still familiarizing myself with matplotlib , but I figured from my data set and setup, I would be able to plot my unit variable on the Y axis and Date on the X Axis and see trends on a daily basis. 我仍然熟悉matplotlib ,但是从我的数据集和设置来看,我将能够在Y轴上绘制单位变量,在X轴上绘制日期,并每天查看趋势。 However, it appears that there is some sort of running total aggregation going on as there is almost a perfectly linear line for the plots from the first date to the last. 但是,似乎出现了某种运行中的总聚合,因为从第一个日期到最后一个日期的图几乎都有一条完美的线性线。 What is off with my configuration that could be causing this? 我的配置有什么问题可能导致这种情况?

Here is my data (I am plotting date and units ): 这是我的数据(我正在绘制dateunits ):

    month       date    units   ler sales
513   May 2019-05-28      811    94   42
514   May 2019-05-29      807    59   28
515   May 2019-05-30      768    68   24
516   May 2019-05-31      675    60   27

Here is my code: 这是我的代码:

df_t_3_months // Data Set

plt.figure(figsize=(10,8))
plt.subplot(211)
plt.plot_date(df_t_3_months['date'],df_t_3_months['units'],xdate=True)

Here is the resulting plot: 这是结果图:

情节

I was expecting a horizontal pattern with peaks and valleys, as one would expect with consistent time series data 我期待的是一个具有峰和谷的水平模式,就像人们希望获得一致的时间序列数据一样

尝试plt.plot(df_t_3_months['date'], df_t_3_months['units'].astype(float))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM