Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Matplotlib: 2-D plot changing line color with 3rd dimension (category)

How do I change the color of a regular 2-D plot according to a third dimension/category? For example, suppose we recorded the coolant temperature of a vehicle with time. We plot that with time on the horizontal axis, and temp on the vertical axis. We also recorded at each time whether the "high temp indicator light" was on or off. When the light was on, we want the plotted light to be red; green if the indicator was off.

It's basically a plot of 3-D data where we assign a particular color of line to the third data dimension (z). I do not want to look at a 3-D plot with 3 axes for this particular application; just a regular 2-D plot changing the line color as appropriate.

like image 897
Pete Avatar asked Nov 14 '22 00:11

Pete


1 Answers

Just look at SciPy.Cookbook.MulticoloredLine

Another approach could be - add on/off ColorBar in the bottom of plot.

hth!

like image 146
Agnius Vasiliauskas Avatar answered Dec 29 '22 01:12

Agnius Vasiliauskas