Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: a4fcdb8cde
Fetching contributors…

Cannot retrieve contributors at this time

169 lines (121 sloc) 3.858 kb

ggthemes

Some extra geoms, scales, and themes for ggplot,

Geoms

  • Tufte range frame
  • Tufte box plot

Themes

Scales

  • Solarized colors
  • The Economist colors.
  • Stata colors, shapes, and linetypes
  • Excel colors (old and new)
  • Tableau colors and shapes
  • Shape scales from William S. Cleveland's Elements of Graphing Data, Tremmel (1995), and Lewandowsky and Spence (1989).
  • Color scale based on Stephen Few's "Practical Rules for Using Color in Charts".

Install

It is probably easiest to use the devtools package to install the latest version:

opts_knit$set(upload.fun = imgur_upload)
opts_chunk$set(fig.width = 5.25, fig.height = 3.75, cache=FALSE)
library("devtools")
install_github("ggthemes", "jrnold")

Examples

library("ggplot2")
library("ggthemes")
dsamp <- diamonds[sample(nrow(diamonds), 1000), ]

Tufte theme and geoms

Minimal theme and geoms based on plots in The Visual Display of Quantitative Information.

(ggplot(mtcars, aes(wt, mpg))
  + geom_point() + geom_rangeframe()
  + theme_tufte())

The Tufte minimal boxplot.

(ggplot(mtcars, aes(factor(cyl), mpg)) 
 + theme_tufte(ticks=FALSE)
 + geom_tufteboxplot())

Economist theme

A theme that approximates the style of plots in The Economist magazine.

(qplot(carat, price, data=dsamp, colour=cut)
 + theme_economist()
 + scale_colour_economist()
 + ggtitle("Diamonds Are Forever"))

Solarized theme

A theme and color and fill scales based on the Solarized palette.

The light theme.

(qplot(carat, price, data=dsamp, colour=cut)
                             + theme_solarized()
                             + scale_colour_solarized("blue"))

The dark theme.

(qplot(carat, price, data=dsamp, colour=cut)
                             + theme_solarized(light=FALSE)
                             + scale_colour_solarized("red"))

Stata theme

Themes and scales (color, fill, linetype, shapes) based on the graph schemes in Stata.

(qplot(carat, price, data=dsamp, colour=cut)
                             + theme_stata() 
                             + scale_colour_stata()
                             + ggtitle("Plot Title"))

Excel 2003 theme

For that classic ugly look and feel. For ironic purposes only. 3D bars and pies not included. Please never use this theme.

(qplot(carat, price, data=dsamp, colour=cut)
 + theme_excel2003() 
 + scale_colour_excel2003())
(ggplot(diamonds, aes(clarity, fill=cut)) 
 + geom_bar()
 + scale_fill_excel2003()
 + theme_excel2003())

Inverse Gray Theme

Inverse of theme_gray, i.e. white plot area and gray background.

(qplot(carat, price, data=dsamp, colour=cut)
 + theme_igray())

Tableau Scales

Color, fill, and shape scales based on those used in the Tableau softare.

(qplot(carat, price, data=dsamp, colour=cut)
 + theme_igray()
 + scale_colour_tableau())
(qplot(carat, price, data=dsamp, colour=cut)
 + theme_igray()
 + scale_colour_tableau("colorblind10"))

Stephen Few's Practical Rules for Using Color ...

Color palette and theme based on Stephen Few's "Practical Rules for Using Color in Charts".

(qplot(carat, price, data=dsamp, colour=cut)
 + theme_few()
 + scale_colour_few())
Jump to Line
Something went wrong with that request. Please try again.