I have a series of X axis axis labels that I overlay on a graph using:
plt.figure(1) ax = plt.subplot(111) ax.bar(Xs, Ys, color="grey",width=1) ax.set_xticks([i+.5 for i in range(0,count)]) ax.set_xticklabels(Xlabs, rotation=270)
Now I want to color each individual label based on what the label is. For example: I want to apply the rule "color the label red if 1 or blue if 0", something like this:
colors = ['blue','red'] ax.set_xticklabels(Xlabs, rotation=270, color = [colors[i] for i in Xlabs])
But this is not true. Is there any way to achieve this?
Tommy source share