HI,
I have troubles getting to wirk a hitogram plot. I have colors in
RGB as tuples of 3 values and also some colors defined as string,
e.g. 'orange'. I get the folowing error:
File "/usr/lib64/python2.7/site-packages/matplotlib/pyplot.py", line 2332, in
hist
ret = ax.hist(x, bins, range, normed, weights, cumulative, bottom,
histtype, align, orientation, rwidth, log, color, label, **kwargs)
File "/usr/lib64/python2.7/site-packages/matplotlib/axes.py", line 7598, in
hist
raise ValueError("color kwarg must have one color per dataset")
ValueError: color kwarg must have one color per dataset
I think it is about the code in this patch:
http://permalink.gmane.org/gmane.comp.python.matplotlib.scm/4600
I hacked a bit the code in colors.py and axes.py to get more debug.
As you can see below it seems a previous value if left in the colors variable
from a previous iteration (I think).
['orange', (0.9468480101059871, 1.0, 0.0)] = colors[:2]
[cut]
pylab.hist(counts[:2], histtype='bar', align='mid', log=True,
bins=len(counts[:2]), color=colors[:2], label=adapternames[:2])
File "/usr/lib64/python2.7/site-packages/matplotlib/pyplot.py", line 2332, in
hist
ret = ax.hist(x, bins, range, normed, weights, cumulative, bottom,
histtype, align, orientation, rwidth, log, color, label, **kwargs)
File "/usr/lib64/python2.7/site-packages/matplotlib/axes.py", line 7598, in
hist
raise ValueError("color kwarg must have one color per dataset: color=%d,
nx=%d, color='%s', nx='%s'" % (len(color), nx, str(color), str(nx)))
ValueError: color kwarg must have one color per dataset: color=2, nx=1,
color='[[ 1. 0.64705882 0. 1. ]
[ 0.94684801 1. 0. 1. ]]', nx='1'
Alternatively I would believe that matplotlib breaks because I have for
different
data points same color ('orange' appears maybe 10x in my colors list) but the
above slice [:2]
excludes this a the cause I am getting right now.
If it matters I generated the colors by this approach:
for _n in range(1,cnt1 + 1):
_h1 = sorted([uniform(0.15, 0.85) for x in range(_n)])
_HSV_tuples1 = [(_h1[x], 1.0, 1.0) for x in range(_n)]
_RGB_tuples1 = map(lambda x: colorsys.hsv_to_rgb(*x), _HSV_tuples1)
but these are mixed together with those defined as string (e.g. 'orange')
before they are sent to matplotlib.
Thank you for you help.
Martin
BTW: Would be nice if the default error messages on the above shown raise() were
more detailed.
------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users