graph from dataframe columns where the curve change its color if date is grater than X
def graph_color(df, date, date_col, x, y): fig, ax = plt.subplots(figsize=(10,5)) up_date = df.loc[df[date_col] <= date] down_date = df.loc[df[date_col] > date] ax.plot(up_date[x], up_date[y], '--') ax.plot(down_date[x], down_date[y], '--') ax.set_title('My Graph') ax.set_ylabel('y_label') ax.set_xlabel('x_label') ax.legend(['Before', 'After']) plt.show() graph_color(df, '2020-04-01', 'date', 'date', 'col_name')