Thomas Guettler wrote:
> this snippet works if there are more (or less) elements in the menMeans
> tuple. If
> there are three, it does not work since the bar command thinks the three
> element tuple is a tuple of rgb values. But it is a (r, g, b) tuple.
> I think it is a bug. Should I create a ticket?
Yes it is a bug. I don't think a ticket will be needed. A quick look
indicates that it will be easy to fix, so I will try to remember to do
it later today. If I haven't done it within 24 hours, send me a reminder.
> I use 0.98.3
> I helped myself by using rgb2hex. But somehow this is not a good solution.
> Maybe colorConverter.to_rgb should return a subclass of tuple called
> This way it would be easier to distinguish between a tuple of rgb values
> and a rgb color tuple.
I don't think this will be necessary, and it would not really solve the
problem in general. I think we already have a solution, but it is not
being used in the bar() method.
> #!/usr/bin/env python
> import numpy as np
> import matplotlib.pyplot as plt
> import matplotlib
> menMeans = (20, 35, 30) # Does work if there are more or less then three
> elements in the tuple
> ind = np.arange(N) # the x locations for the groups
> width = 0.35 # the width of the bars
The call to to_rgb here seems completely unnecessary; cmap returns rgba,
and the color kwarg should accept that. All the to_rgb() is doing is
chopping off the alpha value.
> rects1 = plt.bar(ind, menMeans, width, color=color)
> Traceback (most recent call last):
> line 333, in expose_event
> self._render_figure(self._pixmap, w, h)
> line 75, in _render_figure
> line 261, in draw
> File "/usr/lib64/python2.5/site-packages/matplotlib/figure.py", line
> 759, in draw
> for a in self.axes: a.draw(renderer)
> File "/usr/lib64/python2.5/site-packages/matplotlib/axes.py", line
> 1523, in draw
> File "/usr/lib64/python2.5/site-packages/matplotlib/patches.py", line
> 275, in draw
> rgbFace = colors.colorConverter.to_rgb(self._facecolor)
> File "/usr/lib64/python2.5/site-packages/matplotlib/colors.py", line
> 280, in to_rgb
> raise ValueError('to_rgb: Invalid rgb arg "%s"\n%s' % (str(arg), exc))
> ValueError: to_rgb: Invalid rgb arg "0,490196078431"