Skip to content

alpha affects text and border in geom_label #1924

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

Closed
wants to merge 1 commit into from

Conversation

jiho
Copy link
Contributor

@jiho jiho commented Nov 22, 2016

Alpha is useful to hide plot elements from view. So all pieces of the label should be hidden. I don't see a use case for having only the background of the label transparent.

@hadley
Copy link
Member

hadley commented Jan 24, 2017

The convention in ggplot2 is that for geoms that have both fill and colour, alpha only affects fill. I looked into changing this convention a while back, but it ended up causing more problems than it solved.

@hadley hadley closed this Jan 24, 2017
@jiho
Copy link
Contributor Author

jiho commented Jan 25, 2017

Couldn't an argument be made that, for geom_label the text at least is conceptually part of the "inside" (the outline being the "outside")? If so, I'll modify the code to affect only the text.

My use case for this: I want to use geom_label on a PCA biplot, where it sometimes helps readability compared to geom_text; but even then those plots are often crowded and something that ggplot makes easy is to make objects not well represented by the PCA semi-transparent. That works with geom_text but not geom_label where only the background is transparent.

@hadley
Copy link
Member

hadley commented Jan 25, 2017

As long as you're not mapping the colour, you can always set it to a semi-transparent colour with alpha().

@jiho
Copy link
Contributor Author

jiho commented Jan 25, 2017

I am mapping the colour ;-) to the cos2 in that particular case, which quantifies the representativity of the objects in the projected PCA plane.
EDIT: I am mapping alpha to the cos2 and colour to something else (type of variable/data point).

But, beyond that particular use case, I think that, in any situation where one would map the alpha of the text in geom_text and finally chose geom_label for aesthetical/legibility reasons, one would want the alpha to apply to both the rectangle and the text.

@jiho
Copy link
Contributor Author

jiho commented Jan 25, 2017

BTW, in geom_point, alpha affects both fill and stroke ;-)

This is noticeable now, with the shift from shape=16 (no stroke) to shape=19 (stroke) as the default.

library("ggplot2")
qplot(runif(10), runif(10), size=I(5), alpha=I(0.3), stroke=I(3))

screen shot 2017-01-25 at 15 43 23

@lock
Copy link

lock bot commented Jan 18, 2019

This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/

@lock lock bot locked and limited conversation to collaborators Jan 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants