Plot data from pandas DataFrame, colour of points dependant on a column

前端 未结 3 1661
一整个雨季
一整个雨季 2021-01-21 09:32

I have a pandas DataFrame with 3 columns, shown below.

col1 value flag 1 0 0 2 0.03915 0 3 0.13 1

3条回答
  •  被撕碎了的回忆
    2021-01-21 10:24

    You can pass a vector to the scatter plot as follows

    import matplotlib.pyplot as plt
    
    df = pd.DataFrame(data = {'value':[0, 0.4, 0.13], 'flag':[0,0,1]})
    plt.scatter(df['value'], df.index, c=df['flag'])
    

提交回复
热议问题