Code Monkey home page Code Monkey logo

awtools's Introduction

a_theme

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

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

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:

New 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.
groups<-unique(uspopage$AgeGroup)
uspopage<-uspopage%>%
  filter(uspopage$AgeGroup %in% head(groups,6))
ggplot(uspopage, aes(x=Year, y=Thousands, color=AgeGroup)) + 
  geom_line(size=1) +
  a_primary_color() +
  scale_y_continuous(labels = scales::comma)+
  labs(title="Age distribution of population\nin the U.S., 1900-2002",
       subtitle="Example data from the R Graphics Cookbook.",
       caption="Source: R Graphics Cookbook") +
  a_plex_theme() +
  theme(legend.position="bottom")

A new update to the awtools package sees a new dark theme that is based on the main plex theme.

ggplot(uspopage, aes(x=Year, y=Thousands, color=AgeGroup)) + 
  geom_line(size=1) +
  a_main_color() +
  scale_y_continuous(labels = scales::comma)+
  labs(title="Age distribution of population\nin the U.S., 1900-2002",
       subtitle="Example data from the R Graphics Cookbook.",
       caption="Source: R Graphics Cookbook") +
  a_dark_theme() +
  theme(legend.position="bottom")

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_character(),
##   PRCP = col_double(),
##   SNOW = col_character(),
##   SNWD = col_character(),
##   TAVG = col_integer(),
##   TMAX = col_integer(),
##   TMIN = col_integer(),
##   WDF2 = col_integer(),
##   WDF5 = col_integer(),
##   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 examples

Here is a simple scatterplot with the original a_theme.

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

Here is an example of the color palette.

ggplot(uspopage, aes(x=Year, y=Thousands, fill=AgeGroup)) + 
  geom_area() +
  a_scale_fill() +
  scale_y_continuous(labels = scales::comma)+
  labs(title="Age distribution of population\nin the U.S., 1900-2002",
       subtitle="Example data from the R Graphics Cookbook.",
       caption="Source: R Graphics Cookbook") +
  a_theme() +
  theme(legend.position="bottom")

I also created a reverse of the color palette which is debuted along with the 'a_robot_theme'.

ggplot(uspopage, aes(x=Year, y=Thousands, fill=AgeGroup)) + 
  geom_area() +
  a_reversed_fill() +
  scale_y_continuous(labels = scales::comma)+
  labs(title="Age distribution of population\nin the U.S., 1900-2002",
       subtitle="Example data from the R Graphics Cookbook.",
       caption="Source: R Graphics Cookbook") +
  a_robot_theme() +
  theme(legend.position="bottom")

Finally for work I compare 4 and 6 factors often so I created a stepped version of my color palette.

I also created a reverse of the color palette which is seen below. There has been some work that requires a slightly more editorial style graph so here is also the debut of the 'a_concert_theme'.

groups<-unique(uspopage$AgeGroup)
uspopages<-uspopage%>%
  filter(uspopage$AgeGroup %in% head(groups,4))
ggplot(uspopages, aes(x=Year, y=Thousands, fill=AgeGroup)) + 
  geom_area() +
  a_step_fill() +
  scale_y_continuous(labels = scales::comma)+
  labs(title="Age distribution of population\nin the U.S., 1900-2002",
       subtitle="Example data from the R Graphics Cookbook.",
       caption="Source: R Graphics Cookbook") +
  a_concert_theme() +
  theme(legend.position="bottom")

Finally a little display of a new color palette.

groups<-unique(uspopage$AgeGroup)
uspopage<-uspopage%>%
  filter(uspopage$AgeGroup %in% head(groups,6))
ggplot(uspopage, aes(x=Year, y=Thousands, color=AgeGroup)) + 
  geom_line(size=1) +
  a_main_color() +
  scale_y_continuous(labels = scales::comma)+
  labs(title="Age distribution of population\nin the U.S., 1900-2002",
       subtitle="Example data from the R Graphics Cookbook.",
       caption="Source: R Graphics Cookbook") +
  a_concert_theme() +
  theme(legend.position="bottom")

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.