I want to plot a curve with some measurement data. It is available as an array that contains items of the form [t,b]
, where t is the parameter that I want to plot and b
is a string that describes the status of the measurement equipment. I now want to plot the values of t
and have the line colored depending on the value of b
. My code so far is
import pylab as pl
measurements = [[0, "a"], [1, "b"], [2, "c"]]
times = pl.arange(0, 3, 1)
values = zip(*measurements)[0]
parameters = zip(*measurements)[1]
pl.plot(times, values)
pl.show()
The line should now have different colors, depending on the values in parameters
. How do I do this?