Home > Net >  How to add outliers as separate colored markers to a line plot
How to add outliers as separate colored markers to a line plot

Time:11-19

val             time
5.6     2021-11-18 03:00:00
2.034   2021-11-18 05:00:00
1.171   2021-11-18 07:00:00
3.023   2021-11-18 09:00:00
4.202   2021-11-18 16:00:00
1.202   2021-11-18 17:00:00
5.202   2021-11-18 18:00:00
7.202   2021-11-18 19:00:00
2.202   2021-11-18 20:00:00
12.202  2021-11-18 21:00:00
1.202   2021-11-18 21:00:00

above is my dataframe and i want to plot it (x=time,y=value), and make value plot red where (val>5).

plt.plot(ab['time'], ab['value'], '-gD', markevery=marks, label='line with select markers')

where marks [7.202,12.202] is a list which i created manually. but this does not work. error -: markevery is iterable but not a valid numpy fancy index

enter image description here

  • Related