1

I have ggplot2 v321 and when trying to change background color I got the following error:

Error in element_rect(fill = "green") : 
  could not find function "element_rect" 

when doing:

  plot <- df %>% ggplot2::ggplot(ggplot2::aes(x = x, y = y, color=color)) + 
      ggplot2::geom_point(alpha = 0.1, size = 0, shape = 20) +        
      ggplot2::theme(legend.position = "none", 
                     plot.background = element_rect(fill = "green"))

Do anyone know this error?

thanks

Hugo Silva
  • 199
  • 9
  • 2
    It's a function within `ggplot2`. You need to either append the package name like you've done for the other functions, or (more commonly) just load the library – camille Sep 27 '19 at 22:50
  • I just used your code to plot the dataset `mtcars` and id didn't return the error. – novica Sep 28 '19 at 09:12

0 Answers0