A
Andi Clemens
Hi,
everytime I try to plot a bar with matplotlib I get the following error
message:
Traceback (most recent call last):
File "bar_stacked.py", line 13, in ?
p1 = bar(ind, menMeans, width, color='r', yerr=womenStd)
File "/usr/lib/python2.4/site-packages/matplotlib/pylab.py", line
1641, in bar
ret = gca().bar(*args, **kwargs)
File "/usr/lib/python2.4/site-packages/matplotlib/axes.py", line
2485, in bar
xerr = asarray([xerr]*nbars, Float)
File "/usr/lib/python2.4/site-packages/Numeric/Numeric.py", line 134,
in asarray
return multiarray.array(a, typecode, copy=0, savespace=savespace)
TypeError: a float is required
So I guess it has something to do with Numeric.py, but I can't figure
out what the problem is. I tried to google but found nothing...
Anyone has the same problem? I can plot all kinds of graphics with
matplotlib, but the only type I'm interested in (bars) will not work.
I tried the examples coming with matplotlib, but even those don't work.
Here is the example code which produces the above error:
#!/usr/bin/env python
# a stacked bar plot with errorbars
from pylab import *
N = 5
menMeans = (20, 35, 30, 35, 27)
womenMeans = (25, 32, 34, 20, 25)
menStd = (2, 3, 4, 1, 2)
womenStd = (3, 5, 2, 3, 3)
ind = arange(N) # the x locations for the groups
width = 0.35 # the width of the bars: can also be len(x) sequence
p1 = bar(ind, menMeans, width, color='r', yerr=womenStd)
p2 = bar(ind, womenMeans, width, color='y',
bottom=menMeans, yerr=menStd)
ylabel('Scores')
title('Scores by group and gender')
xticks(ind+width/2., ('G1', 'G2', 'G3', 'G4', 'G5') )
yticks(arange(0,81,10))
legend( (p1[0], p2[0]), ('Men', 'Women') )
show()
Anyone has matplotlib installed and gets the same error?
I need to create some charts for a project I do at work, so maybe there
are other modules out there creating charts??
Andi
--
homepage: http://www.the-grudge.net
ICQ: 9450091
Skype: thegrudge_2
Mozilla Thunderbird 1.5.0.5
Arch Linux
everytime I try to plot a bar with matplotlib I get the following error
message:
Traceback (most recent call last):
File "bar_stacked.py", line 13, in ?
p1 = bar(ind, menMeans, width, color='r', yerr=womenStd)
File "/usr/lib/python2.4/site-packages/matplotlib/pylab.py", line
1641, in bar
ret = gca().bar(*args, **kwargs)
File "/usr/lib/python2.4/site-packages/matplotlib/axes.py", line
2485, in bar
xerr = asarray([xerr]*nbars, Float)
File "/usr/lib/python2.4/site-packages/Numeric/Numeric.py", line 134,
in asarray
return multiarray.array(a, typecode, copy=0, savespace=savespace)
TypeError: a float is required
So I guess it has something to do with Numeric.py, but I can't figure
out what the problem is. I tried to google but found nothing...
Anyone has the same problem? I can plot all kinds of graphics with
matplotlib, but the only type I'm interested in (bars) will not work.
I tried the examples coming with matplotlib, but even those don't work.
Here is the example code which produces the above error:
#!/usr/bin/env python
# a stacked bar plot with errorbars
from pylab import *
N = 5
menMeans = (20, 35, 30, 35, 27)
womenMeans = (25, 32, 34, 20, 25)
menStd = (2, 3, 4, 1, 2)
womenStd = (3, 5, 2, 3, 3)
ind = arange(N) # the x locations for the groups
width = 0.35 # the width of the bars: can also be len(x) sequence
p1 = bar(ind, menMeans, width, color='r', yerr=womenStd)
p2 = bar(ind, womenMeans, width, color='y',
bottom=menMeans, yerr=menStd)
ylabel('Scores')
title('Scores by group and gender')
xticks(ind+width/2., ('G1', 'G2', 'G3', 'G4', 'G5') )
yticks(arange(0,81,10))
legend( (p1[0], p2[0]), ('Men', 'Women') )
show()
Anyone has matplotlib installed and gets the same error?
I need to create some charts for a project I do at work, so maybe there
are other modules out there creating charts??
Andi
--
homepage: http://www.the-grudge.net
ICQ: 9450091
Skype: thegrudge_2
Mozilla Thunderbird 1.5.0.5
Arch Linux