2011/8/16 Eric Firing <efir...@hawaii.edu>:
> On 07/25/2011 08:21 AM, Ben Breslauer wrote:
>> I think that I have found the problem here.  Line2D.draw() (and I
>> presume other Artist subclasses) calls
>>
>> gc.set_foreground(self._color)
>> ...
>> gc.set_alpha(self._alpha)
>>
>> self._color is defined by the color kwarg, whether it be a hex value,
>> 3-tuple, 4-tuple, or something else.  self._alpha is defined by the
>> alpha kwarg, but if the alpha kwarg is None, it is not overwritten with
>> color[3].  Therefore, using color=(R,G,B,A) does not set alpha
>> correctly.  I'm not sure the best (i.e. most matplotlib-like) way to
>> change this so that the A value gets used iff alpha is None, but I've
>> attached a patch that does it one way (diff'ed against the github
>> master, commit 67b1cd650f574f9c53ce).  I know the patch is less than
>> ideal, as it adds kwarg-specific handling into a place where none had
>> previously been done, and it's also in a for loop. Maybe it would be
>> better to do the checking along with the scalex and scaley pops?
>
>
> Alpha handling is a real can of worms; it has gotten better, but as you
> note, there are still problems.  Unfortunately, I don't think your
> proposed solution will work in general, because self._color could be a
> 4-letter string, like "gray", in which case alpha would be set to "y",
> and that would not be good at all.  I suspect the right place to solve
> the problem is down in the GraphicsContext--although I thought I had
> already straightened that out some time ago.
>...
>
> Eric
>
>>
>>
>> Separately, I noticed that
>> backend_bases.GraphicsContextBase.set_foreground claims to only expect
>> an RGB definition, and not an RGBA definition.  As such, I think that it
>> should call
>>
>> self._rgb = colors.colorConverter.to_rgb(fg)
>>
>> instead of
>>
>> self._rgb = colors.colorConverter.to_rgba(fg)
>>
>> since that will make self._rgb a 3-tuple instead of a 4-tuple.
>>
>> Ben
>> ...
>>
Just a remark for this recent proposed patch, as I unfortunately don't
know the implications for the whole codebase.
I believe, that the condition added in the patch
if len(line._color) == 4 and line._alpha == None:
could be adjusted to e.g.:
if isinstance(line._color, tuple) and len(line._color) == 4 and
line._alpha == None

If the alpha value can be set in the color-tuple (for "#RRGGBBAA" some
parsing would be needed, if it is accepted).
Possibly the _alpha should be replace with tha alpha value of the
colour passed this way like
http://matplotlib.sourceforge.net/api/colors_api.html#matplotlib.colors.ColorConverter.to_rgba
"If arg is an RGBA sequence and alpha is not None, alpha will replace
the original A."

But as has been suggested already, it might be better adressed in some
more general way, than in this single function.

 regards,
  vbr

------------------------------------------------------------------------------
uberSVN's rich system and user administration capabilities and model 
configuration take the hassle out of deploying and managing Subversion and 
the tools developers use with it. Learn more about uberSVN and get a free 
download at:  http://p.sf.net/sfu/wandisco-dev2dev
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to