Skip to content

unexpected behavior for alpha in geom_rect() -- possible bug #2790

@rpruim

Description

@rpruim

I'm trying to figure out why alpha is ignored by geom_rect() in the second example below. Is this a bug?

library(ggplot2)
# this works as expected
p <- ggplot() + geom_point(aes(y = eruptions, x = waiting), data = faithful)
p

p + geom_rect(aes(ymin = 2, ymax = 3, xmin = 50, xmax = 80), alpha = 0.2, 
              fill = "red")

# this ignores alpha for some reason
q <- 
  ggplot(aes(y = eruptions, x = waiting), data = faithful) + 
  geom_point()
q

q + geom_rect(aes(ymin = 2, ymax = 3, xmin = 50, xmax = 80), alpha = 0.2, 
              fill = "red")

p$mapping
#> Aesthetic mapping: 
#> <empty>
q$mapping
#> Aesthetic mapping: 
#> * `x` -> `waiting`
#> * `y` -> `eruptions`

Created on 2018-07-31 by the reprex package (v0.2.0).

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