On Thu, Aug 12, 2010 at 10:13 AM, Ben North <[email protected]> wrote:
> Ben Root:
> >Ben North:
> >> Same kind of thing with
> >> the kwarg 'color' instead of 'edgecolor', which is also fixed in my
> >> second recent email.
> >
> > Looking through the code for bar(), I see the same thing occurs for the
> > 'color' keyword argument. So I guess we should fix that as well.
>
> Yes, the second of the emails I sent (pasted below) fixes the behaviour
> for 'edgecolor' and 'color'. Thanks for committing this.
>
> Ben.
>
> ------------------------------------------------------------------------
>
>
> Date: 9 August 2010 09:42
> Subject: Handle 'none' as color and edgecolor for bar()
>
> Hi,
>
> Update to my recent email: perhaps it would make sense to handle the
> 'color' argument in the same way, allowing hollow bars. Combined patch
> below.
>
> Ben.
>
>
>
> --- ORIG-axes.py 2010-07-06 15:43:35.000000000 +0100
> +++ NEW-axes.py 2010-08-09 09:39:44.000256000 +0100
> @@ -4575,15 +4575,17 @@
> if len(linewidth) < nbars:
> linewidth *= nbars
>
> - if color is None:
> - color = [None] * nbars
> + if (color is None
> + or (is_string_like(color) and color.lower() == 'none')):
> + color = [color] * nbars
> else:
> color = list(mcolors.colorConverter.to_rgba_array(color))
> if len(color) < nbars:
> color *= nbars
>
> - if edgecolor is None:
> - edgecolor = [None] * nbars
> + if (edgecolor is None
> + or (is_string_like(edgecolor) and edgecolor.lower() ==
> 'none')):
> + edgecolor = [edgecolor] * nbars
> else:
> edgecolor =
> list(mcolors.colorConverter.to_rgba_array(edgecolor))
> if len(edgecolor) < nbars:
>
I did a little more checking to see if this was needed elsewhere and I think
this is the wrong patch to apply. It appears that
colorConverter.to_rgba_array() might not be correctly handling the case of
'none'. If one passes in a list of colors with some of them being 'none',
everything works nicely. However, if one passes in just 'none', then it
returns an empty array. Note that passing in ['none'] to .to_rgba_array()
produces a length 1 array.
>>> mcolor.colorConvertor.to_rgba_array('none')
array([], shape=(0, 4), dtype=float64)
>>> mcolor.colorConvertor.to_rgba_array(['none'])
array([[ 0., 0., 0., 0.]])
>>> mcolor.colorConvertor.to_rgba_array('r')
array([[ 1., 0., 0., 1.]])
Should this be regarded as a bug?
Ben Root
------------------------------------------------------------------------------
This SF.net email is sponsored by
Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev
_______________________________________________
Matplotlib-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel