Plot pandas dataframe containing NaNs

后端 未结 4 567
星月不相逢
星月不相逢 2020-12-09 16:23

I have GPS data of ice speed from three different GPS receivers. The data are in a pandas dataframe with an index of julian day (incremental from the start of 2009).

4条回答
  •  猫巷女王i
    2020-12-09 17:12

    The reason your not seeing anything is because the default plot style is only a line. But the line gets interupted at NaN's so only multiple consequtive values will be plotted. And the latter doesnt happen in your case. You need to change the style of plotting, which depends on what you want to see.

    For starters, try adding:

    .plot(marker='o')
    

    That should make all data points appear as circles. It easily gets cluttered so adjusting markersize, edgecolor etc might be usefull. Im not fully adjusted to how Pandas is using matplotlib so i often switch to matplotlib myself if plots get more complicated, eg:

    plt.plot(df.R2.index.to_pydatetime(), df.R2, 'o-')
    

提交回复
热议问题