Skip to content

Fix barplot color if none and alpha is set #11640

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

Merged
merged 1 commit into from
Jul 13, 2018

Conversation

timhoffm
Copy link
Member

PR Summary

Fixes #11628.

The actual fix is a bit hacky. It relies on the fact that in Rectangle(edgecolor='none', alpha=0.3) alpha is applied before the color is resolved to [0,0,0,0]. The reverse order would overwrite the alpha of the edgecolor. Maybe the whole color resolution has to be thought through at some point.

Anyway the fix works and has a test. So, it will blow up if the color resolution in Rectangle would be changed. This is good enough for now.

PR Checklist

  • Has Pytest style unit tests
  • Code is PEP 8 compliant

itertools.repeat([0, 0, 0, 0]))

itertools.repeat('none'))
#
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stray pound?

@WeatherGod
Copy link
Member

WeatherGod commented Jul 12, 2018 via email

@timhoffm timhoffm force-pushed the fix-ax-bar-color-none-alpha branch from 9a2c1dc to dd52123 Compare July 12, 2018 23:09
@timhoffm
Copy link
Member Author

@WeatherGod I don't know what you want to say with your comment.

It's ok, that alpha overrides the alpha channel for normal colors. However, I consider it an implementation detail that color='none' is realized as a fully transparent rgba tuple. Logically 'no color' should be invisible irrespective of its alpha.

@WeatherGod
Copy link
Member

WeatherGod commented Jul 12, 2018 via email

@jklymak
Copy link
Member

jklymak commented Jul 13, 2018

I said that "alpha" usually overrides the alpha channel of an rgba tuple spec.

I'm not a huge fan of this convention, but I guess its a quick way to change the alpha of the whole rectangle w/o futzing w/ the rgba values. I'm not clear though what happens if we specify:

edgecolor = [1, 0, 0, 1]
facecolor = [1, 0, 0, 0.5]
alpha = 0.6

The user at some point thought facecolor should be more transparent than edgecolor, so should alpha be multiplied as a quick way to make both more transparent?

@timhoffm
Copy link
Member Author

@jklymak a relative alpha would be too clever. It's even hard to define it in a consistent and intuitive way. Is only one of edgecolor or facecolor absolute? If so which? What should happen for all the combinations of each opaque, semi- or fully transparent? Can you make facecolor='none' edgecolor='...' alpha=... consistent with Line2D linecolor='...' alpha=...?

IMO, using alpha to define foth facecolor and edgecolor absolutely is the more reasonable choice.

@phobson phobson merged commit 8130ea9 into matplotlib:master Jul 13, 2018
@QuLogic QuLogic added this to the v3.0 milestone Jul 13, 2018
@timhoffm timhoffm deleted the fix-ax-bar-color-none-alpha branch July 13, 2018 21:09
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

Successfully merging this pull request may close these issues.

edgecolor argument not working in matplotlib.pyplot.bar
5 participants