1

Currently I have this graph:

From this code: data.Date = pd.to_datetime(data.Date) data.sort_values('Date', inplace=True)

data['mean_Kincaid'] = data.Kincaid.rolling(250, 
min_periods=1).mean()
data.plot(x='Date', y='mean_Kincaid',  
legend=False, title="Kincaid scores over time")

Using this line:

data['mean_Score'] = data.Score.rolling(250, min_periods=1).mean()

I would like to plot the 'mean_Score' on the same graph preferably with a dotted line. My attempt:

data.plot(x='Date', y='mean_Kincaid', y = 'mean_Score',  legend=False, 
title="Kincaid scores over time")
Graham Streich
  • 874
  • 3
  • 15
  • 31

1 Answers1

1

Use get the axes handle from the first plot then use the ax paramater in pandas.DataFrame.plot to plot second line on same axes:

ax = data.plot(x='Data', y='mean_Kincaid',legend=False, title="Kincaid score over time")
data.plot(x='Date', y='mean_Score', ax=ax)
Scott Boston
  • 147,308
  • 15
  • 139
  • 187