thomasp85 / ggforce

Accelerating ggplot2
https://ggforce.data-imaginist.com
Other
916 stars 106 forks source link

Fill is lost in facet_zoom when setting alpha #253

Closed benediktclaus closed 2 years ago

benediktclaus commented 2 years ago

Hi there,

when using a fill for categorical variables and setting an alpha for it, this fill is lost in a facet_zoom(). This is not the case when alpha is not specified.

library(dplyr)
#> 
#> Attache Paket: 'dplyr'
#> Die folgenden Objekte sind maskiert von 'package:stats':
#> 
#>     filter, lag
#> Die folgenden Objekte sind maskiert von 'package:base':
#> 
#>     intersect, setdiff, setequal, union
library(ggplot2)
library(ggforce)

set.seed(20220201)

# With alpha
tibble(
  group = rep(c("a", "b"), each = 10),
  score = c(rnorm(10, 5, 2), rnorm(10, 8, 3))
) %>% 
  ggplot(aes(score, color = group, fill = group)) +
  geom_density(alpha = 0.1) +
  facet_zoom(xlim = c(6, 8))


# Without alpha
set.seed(20220201)
tibble(
  group = rep(c("a", "b"), each = 10),
  score = c(rnorm(10, 5, 2), rnorm(10, 8, 3))
) %>% 
  ggplot(aes(score, color = group, fill = group)) +
  geom_density() +
  facet_zoom(xlim = c(6, 8))

Created on 2022-02-01 by the reprex package (v2.0.1)


Edit

This was caused by using the wrong graphics device backend in RStudio. Everything's fine with AGG.