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

Error with Ribbon Aesthetic in ggplot2 when Using xmin/xmax with Gradient Fill #6357

Open
MathieuYeche opened this issue Mar 7, 2025 · 3 comments

Comments

@MathieuYeche
Copy link
Contributor

MathieuYeche commented Mar 7, 2025

Description:
I have encountered an error when using the ribbon aesthetic with gradient fill in ggplot2. The issue appears to have been introduced by the Gradients in ribbons(#5699) pull request. When combining the use of xmin/xmax aesthetics with gradient fill, the error suggests a typo at line 186 of geom-ribbon.R (likely "tranformed" instead of "transformed"). Removing the typo fixes the issue.

Additionally, on Windows, check_device("gradients", action = "abort", maybe = TRUE) does not work correctly within the default RStudio graphics device (RStudioGD), and the underlyed png support.

Steps to Reproduce:
Run the following code in R:

xr <- seq(1, 101, length.out = 100)
datarr <- data.frame(x = xr, ymin = xr-10, ymax = xr+10)

ggplot(datarr, aes(y = xr, xmin = ymin, xmax = ymax)) +
    geom_ribbon(aes(fill = xr)) +
    scale_fill_gradientn(colors = pals::parula(20))

Observed Error:

Error in `geom_ribbon()`:
! Problem while converting geom to grob.
ℹ Error occurred in the 1st layer.
Caused by error in `draw_group()`:
! object 'tranformed' not found

Expected Behavior:
The code should render a ribbon with a gradient fill without any errors.

R : 4.2.2 (not the most recent)
ggplot2 : 3.5.1.9000

This is my first bug report, so I appreciate any feedback or guidance on further redaction or necessary details.

@teunbrand
Copy link
Collaborator

Thanks for the report! I can reproduce the issue.

This is my first bug report, so I appreciate any feedback or guidance on further redaction or necessary details.

Would you like to try your hand at a first pull request as well?

Additionally, on Windows, check_device("gradients", action = "abort", maybe = TRUE) does not work correctly within the default RStudio graphics device (RStudioGD), and the underlyed png support.

The default Windows device isn't recommended and, as far as I know, not really maintained to support more modern features. I'd like to suggest to switch to the ragg png device or else the cairo png device.

@MathieuYeche
Copy link
Contributor Author

MathieuYeche commented Mar 7, 2025

Would you like to try your hand at a first pull request as well?

Thanks ! I would love to try. In which branch should I push?

@teunbrand
Copy link
Collaborator

After you've made a fork, you can start a new branch from the main branch (you can name it 'fix_6357' for example), make the edits, and lastly open up a PR.
Because it does not involve automatically generated code (like documentation), it should just be a matter of 1 line change, I think.

MathieuYeche added a commit to MathieuYeche/ggplot2 that referenced this issue Mar 7, 2025
@MathieuYeche MathieuYeche mentioned this issue Mar 7, 2025
teunbrand pushed a commit that referenced this issue Mar 7, 2025
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

2 participants