I'm trying to make an errorbar plot with different colors for each point along the x axis. The errorbar chart itself is coming out fine, but it bombs when I try to use a colormap, so I must be doing it wrong. Here's a contrived example of what I'm trying to do:
import matplotlib.pyplot as plt
colors = ["b","g","c","m","y","k","r","g","c","m","y","k",
"b","g","c","m","y","k","r","g","c","m","y","k"]
xlabels = ['A','B','8','14']
xval = [0, 1, 2, 3]
yval = [0, 1, 4, 9]
yerr = [0.5, 0.4, 0.6, 0.9]
cmap = dict(zip( xval,colors))
Now after I run this I can go:
plt.errorbar(xval, yval, yerr=yerr, color='b')
and this gives me the chart shown below (i.e., it works. But when I try to do this:
plt.errorbar(xval, yval, yerr=yerr, color=cmap)
it gives me an error, like " ValueError: to_rgba: Invalid rgba arg "{0: 'b', 1: 'g', 2: 'c', 3: 'm'}"
Is it possible to do what I'm tryng to do? Waht I am trying to do is to have each of the 4 points in the errorbar chart have a different color. I wouldn't need the line connecting the points really. Appreciate any help/advice.