Skip to content

awhstin/awtools

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
R
 
 
man
 
 
 
 
 
 
 
 
 
 
 
 

Project Status: Active - The project has reached a stable, usable state and is being actively developed.

awtools

A simple, distilled, #rstats theme used mainly on www.austinwehrwein.com

devtools::install_github('awhstin/awtools')

The main theme is the a_plex_theme which the fonts are available from Google Fonts:

a_dark_theme shares mostly all the same elements of the main theme but the colors are adjusted to make a dark theme.

Palettes

pal.bands(ppalette,mpalette,spalette,gpalette,bpalette,labels = c('Primary','Flat','Secondary','Gray','Big'))

Examples

a_plex_theme features:

  • grid: [TRUE/FALSE] turns off the main panel grids.
  • noaxis: [TRUE/FALSE] turns off the axis of the plot, seen mainly in maps.
  • emphasis: [‘x’,‘y’,‘xy’] adds a bold to an axis title for emphasis.

All examples are made using the gcookbook package. Let's start with an example using the a_plex_theme with the a_flat_color palette.

ggplot(heightweight,aes(x=heightIn,y=weightLb, color = factor(round(ageYear)))) + 
  geom_point() +
  a_plex_theme() +
  a_flat_color() +
  labs(
    title='Height and Weight',
    subtitle='Sample data of height inches and weight in pounds.',
    caption='Source: R Graphics Cookbook',
    color='Age'
  )

Example of a_dark_theme with the primary color palette.

ggplot(mtcars, aes(mpg, wt)) +
  geom_point(aes(color=factor(carb), size=drat)) +
  labs(x="Fuel efficiency (mpg)", y="Weight (tons)",
       title="Basic scatterplot example",
       subtitle="A demonstration",
       caption="This be a caption") + 
  a_primary_color() +
  a_dark_theme()

And a new a_gray_color and a_gray_palette which is a simple four color grays palette.

lax<-read_csv('https://raw.githubusercontent.com/awhstin/temperaturesv2/master/LAX-NCDC-2015-18.csv') %>% 
  filter(months(DATE)=='January')%>%
  mutate(year=format(DATE,'%Y'),
         month=factor(months(DATE), levels=rev(month.name)))
## Parsed with column specification:
## cols(
##   STATION = col_character(),
##   NAME = col_character(),
##   DATE = col_date(format = ""),
##   AWND = col_double(),
##   PGTM = col_logical(),
##   PRCP = col_double(),
##   SNOW = col_logical(),
##   SNWD = col_logical(),
##   TAVG = col_double(),
##   TMAX = col_double(),
##   TMIN = col_double(),
##   WDF2 = col_double(),
##   WDF5 = col_double(),
##   WSF2 = col_double(),
##   WSF5 = col_double()
## )
ggplot(lax, aes(x=TAVG, y=month, fill=year)) +
  geom_density_ridges(scale=.9, color=NA) +
  a_plex_theme(grid=FALSE) +
  a_gray_fill()
## Picking joint bandwidth of 1.23

Old

The original a_theme uses fonts that can be found and downloaded from Google Fonts:

The new a_robot_theme uses fonts that can be found and downloaded from Google Fonts:

The new a_concert_theme uses fonts that can be found and downloaded from Google Fonts:

Here is a simple scatterplot with the original a_theme.

ggplot(heightweight,aes(x=ageYear,y=heightIn, color=sex))+
  geom_point()+
  a_theme()+
  a_scale_color() +
  labs(title='Height by Age',
       subtitle='Sample data of height in inches by age in years.',
       caption='Source: R Graphics Cookbook')

a_robot_theme gets the name from the use of Roboto and Roboto Slab for the base and plot title fonts.

ggplot(heightweight,aes(x=heightIn,y=ageYear, color = factor(round(ageYear)))) + 
  geom_point() +
  a_robot_theme() +
  a_flat_color() +
  labs(
    title='Height and Age',
    subtitle='Sample data of height inches and age in years.',
    caption='Source: R Graphics Cookbook',
    color='Age'
  )

The a_concert_theme was developed for a more editorial style visualization.

ggplot(climate,aes(x=Year,y=climate$Anomaly10y, color=Source)) + 
  geom_line(size=.75) +
  a_concert_theme() +
  a_primary_color() +
  labs(
    title='Temperature Anomaly',
    subtitle='Anomaly in Celsius, smoothed over ten years',
    caption='Source: R Graphics Cookbook',
    y='Anomaly'
  )

About

misc functions and aesthetic elements for my personal website

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages