0

If you have a dataframe, e.g.:

df = pd.DataFrame({'values': [45,48,52,49,45], 'condition':[-1,-1,1,1,-1]})

Is it possible with matplotlib to plot the 'values' with the color of the marker dependent on the 'condition', e.g. green markers for values where the corresponding condition is 1 and red markers for values where the condition is -1?

Thanks!

Daniel
  • 1
  • 1
  • Look for https://stackoverflow.com/questions/14885895/color-by-column-values-in-matplotlib – Serenity Dec 07 '17 at 10:58
  • Thanks for your help Serenity. I should have added that I am looking to plot the 'values' against the index which is a datetime series. I managed to adapt the code from your link to get it working by moving the index into a column using reset_index() and using that as the x value, which worked perfectly. Thanks again! – Daniel Dec 08 '17 at 07:15

0 Answers0