Hi,
  I am trying to improve my code where I cannot find out why matplotlib-1.1.0 
does not
support colors specified as RG tuples. Here is an example.



import numpy as np
import matplotlib.pyplot as plt

_nums = [160.0, 160.0, 160.0, 95.0, 160.0, 160.0]
_colors = [(0.5019607843137255, 0.0, 0.5019607843137255), (0.5019607843137255, 
0.0, 0.5019607843137255), (0.5019607843137255, 0.0, 0.5019607843137255), 
(0.5019607843137255, 0.0, 0.5019607843137255), (0.5019607843137255, 0.0, 
0.5019607843137255), (0.5019607843137255, 0.0, 0.5019607843137255)]
_legends = ['foo', 'foo', 'foo', 'blah', 'foo', 'foo']

plt.hist(_nums, histtype='bar', align='mid', color=_colors, log=False, 
label=_legends)

plt.show()


The above code gives me:

  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


Mainly, I am suggesting the error message to be improved and to write out how 
many
items were in data, color and legend iterables passed to the function. That 
would help
in some cases albeit not with this example. That needs some other fix. ;)

I would like that one can also pass in a list of HTML-like colors, e.g. 
'F0F8FF' or 0xF0F8FF
would be valid.

Thanks for your comments,
Martin

------------------------------------------------------------------------------
For Developers, A Lot Can Happen In A Second.
Boundary is the first to Know...and Tell You.
Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!
http://p.sf.net/sfu/Boundary-d2dvs2
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to