MatthewBJane / ThemePark

Fun ggplot themes for popular culture

Home Page:http://matthewbjane.com/ThemePark/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Inconsistent naming of "main" colors between themes

lcpilling opened this issue · comments

I thought it would be easy to loop over all 15 themes to create previews for the README. It is possible to do this, but because people have used different names for the "highlight" colors the plots don't always look great when just using light_color_theme compared to dark_color_theme

I suggest encouraging that "light" and "dark" are the extremes, with gradations in the middle? At the moment the naming scheme is quite chaotic.

I'll paste the current list of 15 themes below which tries the same light/medium/dark colors from each. Most are good ("barbie" "terminator" "gameofthrones" etc) - others are clearly designed with different colors as the main highlights (e.g., "oppenheimer")

theme_park_15

# required libraries
library(tidyverse)
library(showtext)
library(devtools)
library(palmerpenguins)
library(patchwork)

# use Palmer Penguins to illustrate data
penguins = palmerpenguins::penguins |> filter(!is.na(sex))

p0 = ggplot(penguins, aes(x = bill_length_mm, y = body_mass_g)) +
  labs(x = 'Bill length (mm)', y = 'Weight (g)') + # caption = 'Penguins from the Palmer Archipelago'
  theme(plot.title.position = 'plot', plot.caption.position = 'plot')
p0

# list of theme file, the names with authors
themes = as.data.frame(t(data.frame(
	c("barbie", "barbie", "Matthew B. Jané"),
	c("oppenheimer","oppenheimer", "Matthew B. Jané & Toki Liam"),
	c("starwars","starwars", "Matthew B. Jané"),
	c("zelda", "zelda", "Alex Slavenko"),
	c("terminator","terminator", "Alex Slavenko"),
	c("spiderman","spiderman", "Velu P.K. Immonen"),
	c("avatar", "avatar", "Velu P.K. Immonen"),
	c("hogwarts","gryffindor", "Begum Ozemek"),
	c("hogwarts","hufflepuff", "Begum Ozemek"),
	c("hogwarts","ravenclaw", "Begum Ozemek"),
	c("hogwarts","slytherin", "Begum Ozemek"),
	c("futurama","futurama", "Tylor J. Harlow"),
	c("simpsons","simpsons", "Tylor J. Harlow"),
	c("lordoftherings","lordoftherings", "Ethan Milne"),
	c("gameofthrones","gameofthrones", "Brennan Antone")
)))
colnames(themes) = c("file","name","author")

# function to get plot for each theme name
get_plot_with_theme = function(file, name, author, p=p0) {

	# get theme_name and source theme
	file_name=paste0("theme_", file)
	theme_name=paste0("theme_", name)
	devtools::source_url(paste0("https://raw.githubusercontent.com/lukepilling/theme_park/main/", file_name ,".R"))
	
	# the themes all have different names and names for the main font option - get the theme and set the font to TRUE
	this_theme = get(theme_name)
	formals(this_theme)[ grepl("font", formalArgs(this_theme)) ][[1]] = TRUE
	
	# add theme to plot
	#    assumes that `dark_color_theme`, `medium_color_theme` and `light_color_theme` are the correct colors for this demo
	#    assumes 
	p + 
		this_theme() + 
		geom_smooth(method='lm', color=get(paste0("dark_color_",name)), fill=get(paste0("light_color_",name))) +
		geom_point(size = 1, alpha = 0.75, color = get(paste0("medium_color_",name))) + 
		labs(title=theme_name, subtitle=paste0("Author(s): ", author))
}

p = themes |> pmap(get_plot_with_theme)

p_all = p[[1]] + p[[2]] + p[[3]] + p[[4]] + p[[5]] + p[[6]] + p[[7]] + p[[8]] + p[[9]] + p[[10]] + p[[11]] + p[[12]] + p[[13]] + p[[14]] + p[[15]] + plot_layout(ncol=1)

ggsave("theme_park_15.png", p_all, width=8, height=60, units="cm")

Another option is to have explicit point_color and other decisions, so that authors do not have to have highlights the same as the light_color but means that these colors are not named in a unique way for each theme

Closing as it is now very out of date due to the move to package system