library(tidyverse)
# Colors too dark
mtcars |>
mutate(carb = factor(carb)) |>
ggplot(aes(carb, fill = carb)) +
geom_bar() +
scale_fill_viridis_d(
option = "magma", begin = 0.1, end = 0.8
) +
theme_bw()
# Colors lighter, but gridlines are visible
mtcars |>
mutate(carb = factor(carb)) |>
ggplot(aes(carb, fill = carb)) +
geom_bar(alpha = 0.8) +
scale_fill_viridis_d(
option = "magma", begin = 0.1, end = 0.8
) +
theme_bw()
# Colors are lighter without transparency
mtcars |>
mutate(carb = factor(carb)) |>
ggplot(aes(x = carb)) +
geom_bar(
aes(fill = stage(
start = carb,
after_scale = colorspace::lighten(fill, 0.15)
))
) +
scale_fill_viridis_d(
option = "magma", begin = 0.1, end = 0.8
) +
theme_bw()
Created on 2024-12-06 with reprex v2.1.1