I have following dataset:
import pandas as pd
import matplotlib.pyplot as plt
dict = {'time':["2017-01-02", "2017-01-03", "2017-01-04", "2017-01-05", "2017-01-06"],'val':[3.2, 10.2, 11.3, 4.9, 2.3],
'class': [0, 1, 1, 0,0]}
df = pd.DataFrame(dict)
df
time val class
0 2017-01-02 3.2 0
1 2017-01-03 10.2 1
2 2017-01-04 11.3 1
3 2017-01-05 4.9 0
4 2017-01-06 2.3 0
I want to plot line for column "val", keeping x axis as 'df.time', meanwhile changing color of line based on 'class' column(when it is zero then for example blue line, when it is 1 then it changes color to red). my plot is as following
but desired is something like this:
Thanks!