Skip to content

Instantly share code, notes, and snippets.

@andrewheiss
Created December 3, 2024 17:44
Show Gist options
  • Save andrewheiss/5083178ab28752c7df399851e343b927 to your computer and use it in GitHub Desktop.
Save andrewheiss/5083178ab28752c7df399851e343b927 to your computer and use it in GitHub Desktop.
library(tidyverse)

# Example data
plot_data <- mpg |> 
  mutate(cyl = factor(cyl)) |> 
  group_by(cyl) |> 
  summarize(n = n())

# ew that yellow is gross
ggplot(plot_data, aes(x = cyl, y = n, fill = cyl)) +
  geom_col() +
  scale_fill_viridis_d(option = "magma")

# Trim the range of the viridis panel
ggplot(plot_data, aes(x = cyl, y = n, fill = cyl)) +
  geom_col() +
  scale_fill_viridis_d(option = "magma", end = 0.8)

Created on 2024-12-03 with reprex v2.1.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment