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

Colourbar transparency #5550

Merged
merged 9 commits into from
Dec 14, 2023
Merged

Colourbar transparency #5550

merged 9 commits into from
Dec 14, 2023

Conversation

teunbrand
Copy link
Collaborator

This PR aims to fix #5085.

It adds an alpha argument to guide_colourbar() and guide_coloursteps() that control the transparency of the bar.
The alpha is applied in the extract_decor() stage, on only affects the display of the bar, not the colour values encoded in the keys (which is fine).

Small demo:

devtools::load_all("~/packages/ggplot2")
#> ℹ Loading ggplot2

ggplot(mpg, aes(displ, hwy, colour = cty, fill = year)) +
  geom_point(shape = 21) +
  guides(
    colour = guide_colourbar(alpha = 0.7),
    fill   = guide_coloursteps(alpha = 0.3)
  )

Created on 2023-11-29 with reprex v2.0.2

Copy link
Member

@thomasp85 thomasp85 left a comment

Choose a reason for hiding this comment

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

LGTM

@thomasp85 thomasp85 added this to the ggplot2 3.5.0 milestone Dec 14, 2023
teunbrand and others added 5 commits December 14, 2023 12:34
Merge branch 'main' into colourbar_alpha

# Conflicts:
#	R/guide-colorbar.R
#	R/guide-colorsteps.R
#	man/guide_colourbar.Rd
#	man/guide_coloursteps.Rd
#	tests/testthat/test-guides.R
@teunbrand teunbrand merged commit 9d1f81c into tidyverse:main Dec 14, 2023
12 checks passed
@teunbrand teunbrand deleted the colourbar_alpha branch December 14, 2023 12:54
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.

Adding override.aes() to guide_colorbar()
2 participants