代码之家  ›  专栏  ›  技术社区  ›  user297850

使用pandas和matplotlib绘制时间序列数据帧并标记某些点

  •  1
  • user297850  · 技术社区  · 6 年前

    x-axis 2014-11-18 2015-1-30 . 如何使用 matplotlib

    enter image description here

    这是我做的,但是看起来很小,如何在一定的时间段内添加一些标记?

    enter image description here

    1 回复  |  直到 6 年前
        1
  •  0
  •   Yuca    6 年前

    最简单的方法是打印两次,第二次打印有额外的样式。关于绘图大小,可以控制 figsize 参数。只需设置一个你喜欢的高度和宽度的元组

    # make sure index is in datetime format
    df_id_ts.index = pd.to_datetime(df_id_ts.index, figsize=(10,6))
    ax = df_id_ts.plot()
    df_id_ts['2014-11-18' : '2015-01-30'].plot(ax = ax, marker = 'ro')