palmerpenguins::penguins %>%
filter(species == "Adelie") %>%
ggplot() +
geom_bar(aes(x = island, fill = sex)) +
labs(x = "", y = "", title = "Adelie", fill = "Sex") +
theme_minimal() +
colorblindr::scale_fill_OkabeIto()I got some floating stacked bars!
data-visualisation
ggplot2
r-how-to
Or did I…
This morning’s fun #rstats discovery, while exploring colorblindr::scale_fill_OkabeIto(): I got some floating stacked bars!
Or did I…? Palmer Penguins to the rescue!🐧🐧🐧
Wait a minute…
The solution? Specify the NA colour using something like this…
colorblindr::scale_fill_OkabeIto(na.value = "grey50"). Or if you prefer, “pink”!
palmerpenguins::penguins %>%
filter(species == "Adelie") %>%
ggplot() +
geom_bar(aes(x = island, fill = sex)) +
labs(x = "", y = "", title = "Adelie", fill = "Sex") +
theme_minimal() +
colorblindr::scale_fill_OkabeIto(na.value = "pink")Reuse
Citation
For attribution, please cite this work as:
Thompson, Cara. 2022. “I Got Some Floating Stacked Bars!”
July 15, 2022. https://www.cararthompson.com/posts/2022-07-15-this-mornings-fun-rstats-discovery/.


