knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
The goal of pdwtheme is to build out the framework for a consistent color and style theme for visualization work that I do.
Note: This is my first package:
1. A lot of it was built using the example written up by: @drsimonj (https://drsimonj.svbtle.com/creating-corporate-colour-palettes-for-ggplot2)
1. I have also been working through the R packages book as I have been working to try to figure out how to turn this into a package and is semi robust.
And the current version from GitHub with:
# install.packages("devtools") devtools::install_github("phildwalker/pdwtheme") # or via remotes::install_github("phildwalker/pdwtheme", ref = "main")
# cols <- c(red = "#d11141", green = "#00b159", blue = "#00aedb", orange = "#f37735", yellow = "#ffc425", `light grey` = "#cccccc", `dark grey` = "#8c8c8c") # cols <- c(`fiji green` = "#6C6F1B", black = "#171409", juniper = "#7B9192", iron = "#C8C9C9", `falu red` = "#701E1E" ) cols <- c(blue = "#18254f", orange = "#dc572e", `dark grey` = "#646464", yellow = "#ef762f") n_seq <- seq_along(cols) image(1, n_seq, t(as.matrix(n_seq)), col = cols, xlab = "", ylab = "", xaxt = "n", yaxt = "n", bty = "n", main = "Colors used for pdw theme") text(0.8, n_seq, names(cols), col = "white") text(1.2, n_seq, cols, col = "white")
This is a basic example which shows you how to solve a common problem:
library(pdwtheme) library(ggplot2) theme_set(theme_minimal()) ## basic example code
# Color by discrete variable using default palette ggplot(iris, aes(Sepal.Width, Sepal.Length, color = Species)) + geom_point(size = 4) + scale_color_pdw()
# Fill by discrete variable with different palette + remove legend (guide) ggplot(mpg, aes(manufacturer, fill = manufacturer)) + geom_bar() + theme(axis.text.x = element_text(angle = 45, hjust = 1)) + scale_fill_pdw(palette = "mixed", guide = "none")
# Fill by discrete variable with different palette + remove legend (guide) ggplot(mpg, aes(manufacturer, fill = manufacturer)) + geom_bar() + theme(axis.text.x = element_text(angle = 45, hjust = 1)) + scale_fill_pdw(palette = "main", guide = "none")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.