knitr::opts_chunk$set(echo = TRUE)
For the future, I intend for this package to contain functions that I use to create plots.
At the moment, there's just theme_carly_presents()
, which simplifies ggplot2::theme_bw()
a bit for a low-resolution format like presentations. I'mm just testing it as a proof of concept. You can see an example I put on SpeakerDeck. I also added several examples below.
devtools::install_github("carlislerainey/ggcarly")
# load packages library(tidyverse) library(ggcarly) # load latent dissent data dissent_df <- read_csv("https://raw.githubusercontent.com/carlislerainey/latent-dissent/master/latent-dissent.csv") %>% glimpse() # plot eta p <- ggplot(dissent_df, aes(x = year, y = eta, group = ccode)) + geom_line(alpha = 0.2) + geom_line(data = filter(dissent_df, country_name %in% c("United States", "Canada", "Mexico", "Russia")), aes(x = year, y = eta, color = country_name), alpha = 1, size = 2) + scale_color_brewer(type = "qual", palette = 2) + labs(title = "A Latent Measure of Dissent", x = "Year", y = "Dissent", color = "Country") # default theme p # bw theme p + theme_bw() # minimal theme p + theme_minimal() # carly_presents p + theme_carly_presents()
# load packages library(ggplot2) library(ggcarly) # scatterplot ggplot(mtcars, aes(wt, mpg, size = hp)) + geom_point(shape = 21) + labs(x = "Weight (1000 lbs.)", y = "Miles Per Gallon", size = "Gross Horsepower") + theme_carly_presents()
# load packages library(ggplot2) library(ggcarly) # barplot ggplot(mpg, aes(class)) + geom_bar() + coord_flip() + theme_carly_presents()
# load packages library(ggplot2) library(ggcarly) # facetted scatterplot ggplot(mpg, aes(displ, hwy)) + geom_point() + facet_wrap(vars(class)) + theme_carly_presents()
# load packages library(ggplot2) library(ggcarly) # dotplot ggplot(mtcars, aes(x = mpg)) + geom_histogram(bins = 10) + theme_carly_presents()
Example from here.
# load packages library(ggplot2) library(ggcarly) # dot-and-box plot g <- ggplot(mpg, aes(manufacturer, cty)) g + geom_boxplot() + geom_dotplot(binaxis='y', stackdir='center', dotsize = .5, fill="red") + theme(axis.text.x = element_text(angle=65, vjust=0.6)) + labs(title="Box plot + Dot plot", subtitle="City Mileage vs Class: Each dot represents 1 row in source data", caption="Source: mpg", x="Class of Vehicle", y="City Mileage") + theme_carly_presents() + theme(axis.text.x = element_text(angle = 60, vjust = 1, hjust = 1))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.