Skip to content

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

Closed
@MathieuYeche

Description

@MathieuYeche

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions