you can do something like the following and specify the color for each bar by
providing a list of colors for the keyword argument 'color'.
import numpy as np
import matplotlib.pyplot as plt
# generate some data
left = np.arange(6)
height = np.random.uniform(size=6)
# plot 3 blue and 3 red bars:
plt.bar(left, height, color=['blue']*3+ ['red']*3)
You second way could be provided by the color list
['red', '0.5']*3 = ['red', '0.5', 'red', '0.5', 'red', '0.5']
On Saturday 23 January 2010 16:36:36 Jeff Layton wrote:
I hate to ask such a newbie question but I am a newb with matplotlib
I want to create a bar chart with, for example, 6 "bars". I want the first
3 bars to be one color and the second 3 bars to be another color. I'm
not entirely sure how to do this - any suggestions?
Alternatively, I would like to create 6 bars where every other bar is
a different color. For example, gray, red, gray, red, gray, red. Any
suggestions on this?