Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch.update_from does not preserve the facecolor when alpha is set. #842

Closed
leejjoon opened this issue Apr 19, 2012 · 4 comments
Closed

Comments

@leejjoon
Copy link
Contributor

Here is an example.

 from matplotlib.patches import Patch

 pa1 = Patch(alpha=None, fc='none', ec='b')
 pb1 = Patch(alpha=1, fc='none', ec='b')

 pa2 = Patch()
 pb2 = Patch()

 pa2.update_from(pa1)
 pb2.update_from(pb1)

 assert pa1.get_fc() == pa2.get_fc()
 assert pb1.get_fc() == pb2.get_fc()

And the second assertion fails.
fc="none" sets facecolor to (0,0,0,0) but when update_from is called,
somehow its alpha value is overridden to 1 (because of alpha=1).
This seems to be a bug but others may think differently.

@WeatherGod
Copy link
Member

There is a bug, but I think it is not what you think it is. Setting alpha to anything but 0.0 or None when fc is 'none' is a contradiction and probably should throw an exception. Furthermore, is it pretty much accepted that the alpha kwarg should override the alpha part of any other colors (so, should the edgecolor in this example be transparent or opaque?).

@WeatherGod
Copy link
Member

Of course, we could adopt semantics where setting a color to 'none' overrides the alpha setting, while letting the alpha override the opaque blue for the edge color in this example... This really begs the need for a Color dtype or something.

@efiring
Copy link
Member

efiring commented Oct 13, 2013

The alpha mess never ends. 'none' really should be different from alpha = 0; but since all we have is RGBA, it was convenient to implement 'none' by setting A to zero.

I think corner cases such as the one pointed out here by @leejjoon will not be solved cleanly short of a major overhaul of color handling, so I am closing this issue.

@efiring efiring closed this as completed Oct 13, 2013
@mdboom
Copy link
Member

mdboom commented Oct 14, 2013

I've reserved MEP21 for an overhaul of color. Finding the time is hard, but short of that, I think it's helpful to keep track of these "major projects" that need to be done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants