Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'master' into stata

Conflicts:
	R/stata.R
  • Loading branch information...
commit affe06d267ad36ee08dea60d9fb17639348e9b87 2 parents 09ca406 + 47a721b
Jeffrey Arnold authored
5 .Rbuildignore
View
@@ -0,0 +1,5 @@
+.gitignore
+roxygen
+README.*
+figure
+.Rhistory
2  .Rinstignore
View
@@ -1,2 +0,0 @@
-roxygen
-.git
21 DESCRIPTION
View
@@ -1,6 +1,6 @@
Package: ggplotJrnold
-Version: 0.0.1
-Date: 2012-9-6
+Version: 0.1.1
+Date: 2012-9-16
Title: ggplot related stuff
Authors@R: c(person("Jeffrey B.", "Arnold", role = c("aut", "cre"),
email = "jeffrey.arnold@gmail.com"))
@@ -8,17 +8,17 @@ Author: Jeffrey B. Arnold <jeffrey.arnold@gmail.com>
Maintainer: Jeffrey B. Arnold <jeffrey.arnold@gmail.com>
Depends:
R (>= 2.15.0),
- ggplot2 (>= 0.9.2),
- scales (>= 0.2.2),
- colorspace,
- proto
+ ggplot2 (>= 0.9.2)
Imports:
- grid
+ colorspace,
+ grid,
+ proto,
+ scales (>= 0.2.2)
Suggests:
- reshape2,
- plyr
+ plyr,
+ reshape2
Description: Some extra themes and scales for ggplot.
-License: GPL-3
+License: GPL-2
URL: http://github.com/jrnold/ggplot-jrnold
BugReports: http://github.com/jrnold/ggplot-jrnold
Collate:
@@ -36,3 +36,4 @@ Collate:
'igray.R'
'ggplotJrnoldPalettes.R'
'few.R'
+ 'ggplotJrnold-package.R'
4 NAMESPACE
View
@@ -51,3 +51,7 @@ export(theme_solarized)
export(theme_stata)
export(theme_tufte)
export(tremmel_shape_pal)
+import(colorspace)
+import(grid)
+import(proto)
+import(scales)
210 R/economist.R
View
@@ -1,28 +1,113 @@
+### Lines or points
+###
+### \itemize{
+### \item 1 Dark blue \url{http://media.economist.com/sites/default/files/imagecache/290-width/images/2012/09/articles/body/20120915_FNC063.png}.
+### \item 2 Mid blue, Dark red \url{http://media.economist.com/sites/default/files/imagecache/290-width/images/print-edition/20120915_INC086.png}. (this appears to be an alternative)
+### \item 2 Dark blue, Mid blue \url{http://media.economist.com/sites/default/files/imagecache/290-width/images/print-edition/20120818_AMC820.png}.
+### \item 3 Dark blue, mid blue, light blue \url{http://media.economist.com/sites/default/files/imagecache/290-width/images/print-edition/20120901_FBC879.png}.
+### \item 4 Dark blue, mid blue, light blue, dark red \url{http://media.economist.com/sites/default/files/imagecache/290-width/images/print-edition/20120901_FBC863.png}.
+### \item 5 Dark blue, mid blue, light blue, dark red, gray \url{http://media.economist.com/sites/default/files/imagecache/290-width/images/2012/08/articles/body/20120818_EUC807.png}.
+### }
+###
+### Bar plots
+### \itemize{
+### \item 1 Dark blue
+### \item 2 Dark blue, mid blue \url{http://media.economist.com/sites/default/files/imagecache/290-width/images/print-edition/20120915_USC091.png}
+### \item 3 \url{http://media.economist.com/sites/default/files/imagecache/290-width/images/print-edition/20120915_IRC092.png}.
+### \item 4
+### \item 5 Dark blue, mid blue, blue gray, light blue, gray \url{http://media.economist.com/sites/default/files/imagecache/290-width/images/print-edition/20120915_USC091.png}.
+### \item 9 \url{http://media.economist.com/sites/default/files/imagecache/290-width/images/print-edition/20120915_EUC094.png}.
+### }
+###
+
##' Economist color palette (discrete)
##'
+##' The primary colors are blues, grays, and greens. Red is not
+##' included (early) in these palettes and should be used to indicate
+##' important data.
+##'
+##'
+##' @param stata Use the palette in the Stata economist scheme.
+##' @param fill Use the fill palette.
+##'
##' @export
##' @examples
-##' show_col(economist_pal()(16))
-economist_pal <- function() {
- manual_pal(unname(ggplotJrnoldPalettes$economist$fg))
+##' library(scales)
+##' show_col(economist_pal()(6))
+##' ## fill palette
+##' show_col(economist_pal(fill=TRUE)(6))
+##' ## RGB values from Stata's economist scheme
+##' show_col(economist_pal(stata=TRUE)(16))
+economist_pal <- function(stata=FALSE, fill=TRUE) {
+ if (stata) {
+ manual_pal(unname(ggplotJrnoldPalettes$economist$stata$fg))
+ } else {
+ colors <- ggplotJrnoldPalettes$economist$fg
+ if (fill) {
+ function(n) {
+ if (n == 1) {
+ i <- "blue_dark"
+ } else if (n == 2) {
+ i <- c("blue_mid", "blue_dark")
+ } else if (n == 3) {
+ i <- c("blue_gray", "blue_dark", "blue_mid")
+ } else if (n == 4) {
+ i <- c("blue_gray", "blue_dark", "blue_mid", "gray")
+ } else if (n %in% 5:6) {
+ ## 20120901_woc904
+ i <- c("blue_gray", "blue_dark", "blue_light", "blue_mid",
+ "green_light", "green_dark")
+ } else if (n == 7) {
+ # 20120818_AMC820
+ i <- c("blue_gray", "blue_dark", "blue_mid", "blue_light",
+ "green_dark", "green_light", "gray")
+ } else if (n >= 8) {
+ # 20120915_EUC094
+ i <- c("blue_gray", "blue_dark", "blue_mid", "blue_light",
+ "green_dark", "green_light", "red_dark", "red_light",
+ "gray")
+ }
+ unname(colors[i][seq_len(n)])
+ }
+ } else {
+ function(n) {
+ if (n <= 3) {
+ # 20120818_AMC20
+ # 20120901_FBC897
+ i <- c("blue_dark", "blue_mid", "blue_light")
+ } else if (n %in% 4:5) {
+ # i <- c("blue_dark", "blue_mid", "blue_light", "red", "gray")
+ i <- c("blue_dark", "blue_mid", "blue_light", "blue_gray", "gray")
+ } else if (n == 6) {
+ # 20120825_IRC829
+ i <- c("green_light", "green_dark", "gray",
+ "blue_gray", "blue_light", "blue_dark")
+ } else if (n > 6) {
+ # 20120825_IRC829
+ i <- c("green_light", "green_dark", "gray",
+ "blue_gray", "blue_light", "blue_dark", "red_dark", "red_light",
+ "brown")
+ }
+ unname(colors[i][seq_len(n)])
+ }
+ }
+ }
}
+
##' Economist color scales
##'
##' Color scales using the colors in the Economist graphics. These scales use
##' RGB values and ordering of the colors in the Stata economist scheme.
##'
##' @inheritParams ggplot2::scale_colour_hue
+##' @inheritParams economist_pal
##' @family colour scales
##' @rdname scale_economist
+##' @seealso \code{\link{theme_economist}} for examples.
##' @export
-##' @examples
-##' dsamp <- diamonds[sample(nrow(diamonds), 1000), ]
-##' (d <- qplot(carat, price, data=dsamp, colour=clarity)
-##' + theme_economist()
-##' + scale_colour_economist() )
-scale_colour_economist <- function(...) {
- discrete_scale("colour", "economist", economist_pal(), ...)
+scale_colour_economist <- function(stata=FALSE, ...) {
+ discrete_scale("colour", "economist", economist_pal(stata=stata), ...)
}
#' @export
@@ -31,8 +116,8 @@ scale_color_economist <- scale_colour_economist
#' @export
#' @rdname scale_economist
-scale_fill_economist <- function(...) {
- discrete_scale("fill", "economist", economist_pal(), ...)
+scale_fill_economist <- function(stata=FALSE, ...) {
+ discrete_scale("fill", "economist", economist_pal(stata=stata), ...)
}
@@ -43,17 +128,38 @@ scale_fill_economist <- function(...) {
##' @param base_size base font size
##' @param base_family base font family
##' @param horizontal \code{logical}. Horizontal axis lines?
-##' @param dkplot \code{logical} Darker background for plot region?
+##' @param dkpanel \code{logical} Darker background for panel region?
+##' @param stata \code{logical} Use RGB values from Stata's
+##' economist scheme.
##' @export
##' @family themes
##' @examples
##' dsamp <- diamonds[sample(nrow(diamonds), 1000), ]
-##' (d <- qplot(carat, price, data=dsamp, colour=clarity)
-##' + theme_economist()
-##' + scale_colour_economist() )
-theme_economist <- function(base_size = 12, base_family="",
- horizontal=TRUE, dkplot=FALSE) {
- bgcolors <- ggplotJrnoldPalettes$economist$bg
+##' q <- qplot(carat, price, data=dsamp, colour=clarity)
+##' ## Standard
+##' q + theme_economist() + scale_colour_economist()
+##' ## Stata colors
+##' q + theme_economist(stata=TRUE) + scale_colour_economist(stata=TRUE)
+##' ## Darker plot region
+##' q + theme_economist(dkpanel=TRUE) + scale_colour_economist(stata=TRUE)
+##' ## Change axis lines to vertical
+##' (q + theme_economist(horizontal=FALSE)
+##' + scale_colour_economist() + coord_flip()
+##' + ggtitle("Diamonds Are Forever"))
+theme_economist <- function(base_size = 10, base_family="",
+ horizontal=TRUE, dkpanel=FALSE, stata=FALSE) {
+ if (stata) {
+ bgcolors <- ggplotJrnoldPalettes$economist$stata$bg
+ } else {
+ bgcolors <- ggplotJrnoldPalettes$economist$bg
+ }
+ ## From measurements
+ ## Ticks = 1/32 in, with margin about 1.5/32
+ ## Title = 3/32 in (6 pt)
+ ## Legend Labels = 2.5/32 in (5pt)
+ ## Axis Labels = 2
+ ## Axis Titles and other text ~ 2
+ ## Margins: Top/Bottom = 6/32, sides = 5/32
ret <-
theme(# Basic
line = element_line(colour = "black", size = 0.5,
@@ -62,9 +168,9 @@ theme_economist <- function(base_size = 12, base_family="",
colour = NA, size = 0.5, linetype = 1),
text = element_text(family = base_family, face = "plain",
colour = "black", size = base_size, hjust = 0.5, vjust = 0.5,
- angle = 0, lineheight = 0.9),
+ angle = 0, lineheight = 1),
## Axis
- axis.text = element_text(size = rel(0.8)),
+ axis.text = element_text(size = rel(1)),
axis.line = element_line(size = rel(0.8)),
axis.line.y = element_blank(),
axis.text.x = element_text(vjust = 1),
@@ -72,46 +178,48 @@ theme_economist <- function(base_size = 12, base_family="",
## I cannot figure out how to get ggplot to do 2 levels of ticks
axis.ticks = element_line(),
axis.ticks.y = element_blank(),
+ axis.title = element_text(size = rel(1)),
axis.title.x = element_text(),
axis.title.y = element_text(angle = 90),
- axis.ticks.length = grid::unit(-0.2 , "cm"),
- axis.ticks.margin = grid::unit(0.6, "cm"),
+ # axis.ticks.length = unit(-1/32, "in"),
+ axis.ticks.length = unit(-base_size * 0.5 , "points"),
+ # axis.ticks.margin = unit(3/72, "in"),
+ axis.ticks.margin = unit(base_size * 1.25, "points"),
legend.background = element_rect(linetype=0),
- legend.margin = grid::unit(0.2, "cm"),
+ legend.margin = unit(base_size * 1.5, "points"),
legend.key = element_rect(linetype=0),
- legend.key.size = grid::unit(1.2, "lines"),
+ legend.key.size = unit(1.2, "lines"),
legend.key.height = NULL,
legend.key.width = NULL,
- legend.text = element_text(size = rel(0.8)),
+ legend.text = element_text(size = rel(1.25)),
legend.text.align = NULL,
- legend.title = element_text(size = rel(0.8), face = "bold",
- hjust = 0),
+ legend.title = element_text(size = rel(1), hjust = 0),
legend.title.align = NULL,
- legend.position = "right",
+ legend.position = "top",
legend.direction = NULL,
legend.justification = "center",
## legend.box = element_rect(fill = palette_economist['bgdk'], colour=NA, linetype=0),
## Economist only uses vertical lines
panel.background = element_rect(linetype=0),
panel.border = element_blank(),
- panel.grid.major = element_line(colour = "white", size=rel(2)),
+ panel.grid.major = element_line(colour = "white", size=rel(1.75)),
panel.grid.minor = element_blank(),
- panel.margin = grid::unit(0.25, "lines"),
+ panel.margin = unit(0.25, "lines"),
strip.background = element_rect(fill = bgcolors['edkbg'],
colour = NA, linetype=0),
- strip.text = element_text(size = rel(0.8)),
+ strip.text = element_text(size = rel(1.25)),
strip.text.x = element_text(),
strip.text.y = element_text(angle = -90),
plot.background = element_rect(fill = bgcolors['ebg'], colour=NA),
- plot.title = element_text(size = rel(1.2), hjust=0),
- plot.margin = grid::unit(c(1, 1, 0.5, 0.5), "lines"),
+ plot.title = element_text(size = rel(1.5), hjust=0, face="bold"),
+ plot.margin = unit(c(6, 5, 6, 5) * 2, "points"),
complete = TRUE)
if (horizontal) {
ret <- ret + theme(panel.grid.major.x = element_blank())
} else {
ret <- ret + theme(panel.grid.major.y = element_blank())
}
- if (dkplot==TRUE) {
+ if (dkpanel==TRUE) {
ret <- ret + theme(panel.background=element_rect(fill = bgcolors['edkbg']))
}
ret
@@ -120,46 +228,14 @@ theme_economist <- function(base_size = 12, base_family="",
## - white background http://junkcharts.typepad.com/.shared/image.html?/photos/uncategorized/2008/04/18/econ_anglosaxon.gif
## - white and gray http://www.economist.com/blogs/graphicdetail/2012/09/daily-chart-3
-## RGB values from Stata economist scheme
-
-
-## From latticeExtra::theEconomist.theme
-## palette_economist_1 <- c(dkblue="#00526D", ltblue="#00A3DB", dkred="#7A2713",
-## yellow="#939598", ltblue2="#6CCFF6")
-
## Palette
## 3 color http://www.economist.com/blogs/graphicdetail/2012/08/daily-chart-olympics-4 (blue, red, lt red)
## 3 and 4 colors http://www.economist.com/node/21561909
## 5 colors http://www.economist.com/node/21560601, http://www.economist.com/blogs/graphicdetail/2012/08/daily-chart-6
-## pal_economist_colour <-
-## manual_pal(c(dkblue="#014B62", blue="#00A0D8", ltblue="#79D3F6",
-## red="#781D01", gray="#ACABAC"))
-
-##
## 1 color http://www.economist.com/node/21561883
## 2 color http://www.economist.com/node/21560572
## 3 color http://www.economist.com/node/21560582
## 4 color http://www.economist.com/blogs/graphicdetail/2012/09/focus
## 6 color http://junkcharts.typepad.com/.a/6a00d8341e992c53ef01538e032bd5970b-pi
## 7 color
-## http://www.economist.com/node/14941181?story_id=14941181, http://www.economist.com/blogs/graphicdetail/2012/07/focus-4
-## 8 color http://www.economist.com/node/16834943?story_id=16834943
-## pal_economist_fill <- function(n) {
-## colors <- c(bluegray="#6794a7", dkblue="#014D65", blue="01a29d9",
-## gray="ADADAD", ltgreen="#7AD2F6", ltgreen2="#76C0C1",
-## green="#00887E")
-## if (n == 1) {
-## colors['dkblue']
-## } else if (n == 2) {
-## colors[c("blue", "dkblue")]
-## } else {
-## colors[1:n]
-## }
-## }
-
-## RGB values from Stata economist scheme
-## pal_economist_fill <-
-## manual_pal(c(blue="#014D63", bluegray="#6895A7", gray="#ACADAF",
-## ltblue="#009FD7", ltgreen="#74BBBE", red="#762918",
-## green="#02847B", ltblue2="#75CFF3"))
2  R/excel.R
View
@@ -5,6 +5,7 @@
##' @param fill \code{logical} Use the fill palette?
##' @export
##' @examples
+##' library(scales)
##' show_col(excel2003_pal()(8))
##' show_col(excel2003_pal(fill=TRUE)(8))
excel2003_pal <- function(fill=FALSE) {
@@ -88,6 +89,7 @@ theme_excel2003 <- function(horizontal=TRUE, base_size=12, base_family="") {
##' and \code{\link{scale_colour_excel10}} for examples.
##' @export
##' @examples
+##' library(scales)
##' show_col(excel10_pal()(10))
excel10_pal <- function() {
manual_pal(ggplotJrnoldPalettes$excel$excel10)
1  R/few.R
View
@@ -13,6 +13,7 @@
##' @export
##' @param palette One of "medium", "dark", or "light"
##' @examples
+##' library(scales)
##' show_col(few_pal()(7))
##' show_col(few_pal("dark")(7))
##' show_col(few_pal("light")(7))
9 R/ggplotJrnold-package.R
View
@@ -0,0 +1,9 @@
+##' ggplotJrnold
+##'
+##' This package contains extra miscellaneous themes, scales, and
+##' geoms, and function for and related to \bold{ggplot2}.
+##'
+##' @name ggplotJrnold
+##' @docType package
+##' @import colorspace grid proto scales
+NULL
81 R/ggplotJrnoldPalettes.R
View
@@ -49,26 +49,69 @@ ggplotJrnoldPalettes <- {
## Economist colors
x$economist <- list()
- x$economist$bg <- c(## Background
- ebg = rgb(198,211,223, max=255),
- edkbg = rgb(178,191,203, max=255))
+ ## Colors from http://vis.stanford.edu/color-names/analyzer/
+ ## x$economist$fg <-
+ ## c(red_dark="#621e15", read_light="#e59076",
+ ## blue_mid="#128dcd", blue_dark="#083c52", blue_mid="#64c5f2",
+ ## green_light="#61afaf", green_dark="#0f7369", gray="#9c9da1",
+ ## # From color picker of png
+ ## blue_gray="#6794a7")
+
+ ## Colors picked from pngs
+ ## bg : d5e4eb
+ ## bgdk : c3d6df
+ x$economist$bg <-
+ c(ebg = "#d5e4eb", edkbg = "#c3d6df")
+ ## From png 20120818_AMC820.png
+ ## blue_gray = 6794a7
+ ## blue_dark = 014d64
+ ## green_light = 76c0c1
+ ## blue_mid = 01a2d9
+ ## blue_light = 7ad2f6
+ ## green_dark = 00887d
+ ## gray = adadad
+ ## 20120915_EUC094.png
+ ## blue_light: 7bd3f6
+ ## red_dark = 7c260b
+ ## red_light = ee8f71
+ ## green_light = 76c0c1
+ ## Colors from Stata economist scheme
+ ## 20120915_woc77.png
+ ## brown a18376
x$economist$fg <-
- c(
- edkblue = rgb(62,100,125, max=255),
- emidblue = rgb(123,146,168, max=255),
- eltblue = rgb(130,192,233, max=255),
- emerald = rgb(45,109,102, max=255),
- erose = rgb(191,161,156, max=255),
- ebblue = rgb(0,139,188, max=255),
- eltgreen = rgb(151,182,176, max=255),
- stone = rgb(215,210,158, max=255),
- navy = rgb(26,71,111, max=255),
- maroon = rgb(144,53,59, max=255),
- brown = rgb(156,136,71, max=255),
- lavender = rgb(147,141,210, max=255),
- teal = rgb(110,142,132, max=255),
- cranberry=rgb(193, 5, 52, max=255),
- khaki = rgb(202,194, 126, max=255))
+ c(blue_gray = "#6794a7",
+ blue_dark = "#014d64",
+ green_light = "#76c0c1",
+ blue_mid = "#01a2d9",
+ blue_light = "#7ad2f6",
+ green_dark = "#00887d",
+ gray = "#adadad",
+ blue_light = "#7bd3f6",
+ red_dark = "#7c260b",
+ red_light = "#ee8f71",
+ green_light = "#76c0c1",
+ brown = "#a18376")
+ x$economist$stata <-
+ list(bg=
+ c(## Background
+ ebg = rgb(198,211,223, max=255),
+ edkbg = rgb(178,191,203, max=255)),
+ fg=
+ c(edkblue = rgb(62,100,125, max=255),
+ emidblue = rgb(123,146,168, max=255),
+ eltblue = rgb(130,192,233, max=255),
+ emerald = rgb(45,109,102, max=255),
+ erose = rgb(191,161,156, max=255),
+ ebblue = rgb(0,139,188, max=255),
+ eltgreen = rgb(151,182,176, max=255),
+ stone = rgb(215,210,158, max=255),
+ navy = rgb(26,71,111, max=255),
+ maroon = rgb(144,53,59, max=255),
+ brown = rgb(156,136,71, max=255),
+ lavender = rgb(147,141,210, max=255),
+ teal = rgb(110,142,132, max=255),
+ cranberry=rgb(193, 5, 52, max=255),
+ khaki = rgb(202,194, 126, max=255)))
## Excel Colors
x$excel <-
1  R/solarized.R
View
@@ -28,6 +28,7 @@ solarized_rebase <- function(light=TRUE) {
##' @param accent \code{character} Primary accent color.
##' @export
##' @examples
+##' library(scales)
##' show_col(solarized_pal()(2))
##' show_col(solarized_pal()(3))
##' show_col(solarized_pal("red")(4))
15 R/stata.R
View
@@ -5,6 +5,7 @@
##' @param scheme \code{character}. One of "s2color", "s1rcolor", "s1color", or "mono".
##' @export
##' @examples
+##' library(scales)
##' show_col(stata_pal("s2color")(15))
##' show_col(stata_pal("s1rcolor")(15))
##' show_col(stata_pal("s1color")(15))
@@ -213,7 +214,7 @@ theme_stata <- function(scheme="s2color", base_size=11, base_family="") {
legend.background = element_rect(linetype=1),
legend.margin = grid::unit(stata_margins$small / 100, "npc"),
legend.key = element_rect(fill="white", linetype=0),
- legend.key.size = grid::unit(1.2, "lines"),
+ legend.key.size = unit(1.2, "lines"),
legend.key.height = NULL,
legend.key.width = NULL,
legend.text = element_text(size = rel(relsz['medsmall'])),
@@ -280,12 +281,12 @@ theme_stata <- function(scheme="s2color", base_size=11, base_family="") {
axis.title = element_text(colour=fgcolor, size=rel(1.2)),
axis.title.x = element_text(),
axis.title.y = element_text(angle = 90, vjust=0.1),
- axis.ticks.length = grid::unit(0.30, "cm"),
- axis.ticks.margin = grid::unit(0.05, "cm"),
+ axis.ticks.length = unit(0.30, "cm"),
+ axis.ticks.margin = unit(0.05, "cm"),
legend.background = element_rect(linetype=1),
- legend.margin = grid::unit(0.2, "cm"),
+ legend.margin = unit(0.2, "cm"),
legend.key = element_rect(fill=bgcolor, linetype=0),
- legend.key.size = grid::unit(1.2, "lines"),
+ legend.key.size = unit(1.2, "lines"),
legend.key.height = NULL,
legend.key.width = NULL,
legend.text = element_text(size = rel(0.8)),
@@ -304,14 +305,14 @@ theme_stata <- function(scheme="s2color", base_size=11, base_family="") {
panel.grid.major.x = element_blank(),
panel.grid.minor = element_blank(),
## panel.grid.minor = element_line(colour=stata_colors['gs5']),
- panel.margin = grid::unit(0.25, "lines"),
+ panel.margin = unit(0.25, "lines"),
strip.background = element_rect(linetype=1, fill=color_strip),
strip.text = element_text(size = rel(0.8)),
strip.text.x = element_text(vjust=0.5),
strip.text.y = element_text(angle = -90),
plot.background = element_rect(colour=NA),
plot.title = element_text(size = rel(2), hjust=0.5, vjust=0.5),
- plot.margin = grid::unit(c(1, 1, 0.5, 0.5), "lines"),
+ plot.margin = unit(c(1, 1, 0.5, 0.5), "lines"),
complete=TRUE)
}
}
1  R/tableau.R
View
@@ -19,6 +19,7 @@
##' \url{http://vis.stanford.edu/files/2012-ColorNameModels-CHI.pdf}.
##'
##' @examples
+##' library(scales)
##' show_col(tableau_color_pal("tableau20")(20))
##' show_col(tableau_color_pal("tableau10")(10))
##' show_col(tableau_color_pal("tableau10medium")(10))
10 R/utils.R
View
@@ -22,14 +22,15 @@ cpaste <- function(..., sep=", ", collapse=NULL, and=TRUE) {
##' Show shapes
##'
-##' A quick and dirty way to show shapes for a palette.
+##' A quick and dirty way to show shapes.
##'
##' @export
##' @param shapes A numeric or character vector of shapes. See
##' \code{\link{par}}.
-##' @seealso \code{\link{show_col}}, \code{\link{show_linetypes}}
+##' @seealso \code{\link[scales]{show_col}}, \code{\link{show_linetypes}}
##'
##' @examples
+##' library(scales)
##' show_shapes(shape_pal()(5))
show_shapes <- function(shapes) {
n <- length(shapes)
@@ -50,14 +51,15 @@ show_shapes <- function(shapes) {
##' Show linetypes
##'
-##' A quick and dirty way to show linetypes for a palette.
+##' A quick and dirty way to show linetypes.
##'
##' @export
##' @param linetypes A character vector of linetypes. See
##' \code{\link{par}}.
-##' @seealso \code{\link{show_col}}, \code{\link{show_linetypes}}
+##' @seealso \code{\link[scales]{show_col}}, \code{\link{show_linetypes}}
##'
##' @examples
+##' library(scales)
##' show_shapes(linetype_pal()(3))
show_linetypes <- function(linetypes) {
n <- length(linetypes)
5 README.Rmd
View
@@ -74,8 +74,9 @@ magazine.
```{r}
(qplot(carat, price, data=dsamp, colour=cut)
- + theme_economist()
- + scale_colour_economist())
+ + theme_economist()
+ + scale_colour_economist()
+ + ggtitle("Diamonds Are Forever"))
```
## Solarized theme
26 README.md
View
@@ -59,7 +59,7 @@ Quantitative Information*.
theme_tufte())
```
-![plot of chunk unnamed-chunk-3](http://i.imgur.com/0P7NT.png)
+![plot of chunk unnamed-chunk-3](http://i.imgur.com/ugn1m.png)
The Tufte minimal boxplot.
@@ -70,7 +70,7 @@ The Tufte minimal boxplot.
geom_tufteboxplot())
```
-![plot of chunk unnamed-chunk-4](http://i.imgur.com/dlVD6.png)
+![plot of chunk unnamed-chunk-4](http://i.imgur.com/wpHpV.png)
## Economist theme
@@ -81,10 +81,10 @@ magazine.
```r
(qplot(carat, price, data = dsamp, colour = cut) + theme_economist() +
- scale_colour_economist())
+ scale_colour_economist() + ggtitle("Diamonds Are Forever"))
```
-![plot of chunk unnamed-chunk-5](http://i.imgur.com/GPK1U.png)
+![plot of chunk unnamed-chunk-5](http://i.imgur.com/yYTRV.png)
## Solarized theme
@@ -99,7 +99,7 @@ The light theme.
scale_colour_solarized("blue"))
```
-![plot of chunk unnamed-chunk-6](http://i.imgur.com/fU8bH.png)
+![plot of chunk unnamed-chunk-6](http://i.imgur.com/Pd3QU.png)
The dark theme.
@@ -110,7 +110,7 @@ The dark theme.
scale_colour_solarized("red"))
```
-![plot of chunk unnamed-chunk-7](http://i.imgur.com/UuCJ2.png)
+![plot of chunk unnamed-chunk-7](http://i.imgur.com/2Nn7O.png)
## Stata theme
@@ -124,7 +124,7 @@ schemes in Stata.
scale_colour_stata() + ggtitle("Plot Title"))
```
-![plot of chunk unnamed-chunk-8](http://i.imgur.com/bAhTM.png)
+![plot of chunk unnamed-chunk-8](http://i.imgur.com/Ommq8.png)
## Excel 2003 theme
@@ -138,7 +138,7 @@ and pies not included. Please never use this theme.
scale_colour_excel2003())
```
-![plot of chunk unnamed-chunk-9](http://i.imgur.com/PYpD0.png)
+![plot of chunk unnamed-chunk-9](http://i.imgur.com/U8Dfn.png)
@@ -147,7 +147,7 @@ and pies not included. Please never use this theme.
theme_excel2003())
```
-![plot of chunk unnamed-chunk-10](http://i.imgur.com/MwhqQ.png)
+![plot of chunk unnamed-chunk-10](http://i.imgur.com/BHX8v.png)
## Inverse Gray Theme
@@ -159,7 +159,7 @@ Inverse of `theme_gray`, i.e. white plot area and gray background.
(qplot(carat, price, data = dsamp, colour = cut) + theme_igray())
```
-![plot of chunk unnamed-chunk-11](http://i.imgur.com/OyDy8.png)
+![plot of chunk unnamed-chunk-11](http://i.imgur.com/2TWLG.png)
@@ -173,7 +173,7 @@ Color, fill, and shape scales based on those used in the Tableau softare.
scale_colour_tableau())
```
-![plot of chunk unnamed-chunk-12](http://i.imgur.com/mSOHc.png)
+![plot of chunk unnamed-chunk-12](http://i.imgur.com/7DHn1.png)
@@ -182,7 +182,7 @@ Color, fill, and shape scales based on those used in the Tableau softare.
scale_colour_tableau("colorblind10"))
```
-![plot of chunk unnamed-chunk-13](http://i.imgur.com/tQPO6.png)
+![plot of chunk unnamed-chunk-13](http://i.imgur.com/XLjKW.png)
## Stephen Few's Practical Rules for Using Color ...
@@ -195,6 +195,6 @@ Color palette and theme based on Stephen Few's ["Practical Rules for Using Color
scale_colour_few())
```
-![plot of chunk unnamed-chunk-14](http://i.imgur.com/eVY90.png)
+![plot of chunk unnamed-chunk-14](http://i.imgur.com/NkIH8.png)
19 man/economist_pal.Rd
View
@@ -2,12 +2,25 @@
\alias{economist_pal}
\title{Economist color palette (discrete)}
\usage{
- economist_pal()
+ economist_pal(stata = FALSE, fill = TRUE)
+}
+\arguments{
+ \item{stata}{Use the palette in the Stata economist
+ scheme.}
+
+ \item{fill}{Use the fill palette.}
}
\description{
- Economist color palette (discrete)
+ The primary colors are blues, grays, and greens. Red is
+ not included (early) in these palettes and should be used
+ to indicate important data.
}
\examples{
-show_col(economist_pal()(16))
+library(scales)
+show_col(economist_pal()(6))
+## fill palette
+show_col(economist_pal(fill=TRUE)(6))
+## RGB values from Stata's economist scheme
+show_col(economist_pal(stata=TRUE)(16))
}
1  man/excel10_pal.Rd
View
@@ -9,6 +9,7 @@
\url{http://vis.stanford.edu/color-names/analyzer/}.
}
\examples{
+library(scales)
show_col(excel10_pal()(10))
}
\seealso{
1  man/excel2003_pal.Rd
View
@@ -12,6 +12,7 @@
only.
}
\examples{
+library(scales)
show_col(excel2003_pal()(8))
show_col(excel2003_pal(fill=TRUE)(8))
}
1  man/few_pal.Rd
View
@@ -18,6 +18,7 @@
thin, and medium otherwise. }
}
\examples{
+library(scales)
show_col(few_pal()(7))
show_col(few_pal("dark")(7))
show_col(few_pal("light")(7))
11 man/ggplotJrnold.Rd
View
@@ -0,0 +1,11 @@
+\docType{package}
+\name{ggplotJrnold}
+\alias{ggplotJrnold}
+\alias{ggplotJrnold-package}
+\title{ggplotJrnold}
+\description{
+ This package contains extra miscellaneous themes, scales,
+ and geoms, and function for and related to
+ \bold{ggplot2}.
+}
+
17 man/scale_economist.Rd
View
@@ -4,29 +4,28 @@
\alias{scale_fill_economist}
\title{Economist color scales}
\usage{
- scale_colour_economist(...)
+ scale_colour_economist(stata = FALSE, ...)
- scale_color_economist(...)
+ scale_color_economist(stata = FALSE, ...)
- scale_fill_economist(...)
+ scale_fill_economist(stata = FALSE, ...)
}
\arguments{
\item{...}{Other arguments passed on to
\code{\link{discrete_scale}} to control name, limits,
breaks, labels and so forth.}
+
+ \item{stata}{Use the palette in the Stata economist
+ scheme.}
}
\description{
Color scales using the colors in the Economist graphics.
These scales use RGB values and ordering of the colors in
the Stata economist scheme.
}
-\examples{
-dsamp <- diamonds[sample(nrow(diamonds), 1000), ]
-(d <- qplot(carat, price, data=dsamp, colour=clarity)
- + theme_economist()
- + scale_colour_economist() )
-}
\seealso{
+ \code{\link{theme_economist}} for examples.
+
Other colour scales: \code{\link{scale_color_excel10}},
\code{\link{scale_color_excel2003}},
\code{\link{scale_color_few}},
6 man/show_linetypes.Rd
View
@@ -9,12 +9,14 @@
\code{\link{par}}.}
}
\description{
- A quick and dirty way to show linetypes for a palette.
+ A quick and dirty way to show linetypes.
}
\examples{
+library(scales)
show_shapes(linetype_pal()(3))
}
\seealso{
- \code{\link{show_col}}, \code{\link{show_linetypes}}
+ \code{\link[scales]{show_col}},
+ \code{\link{show_linetypes}}
}
6 man/show_shapes.Rd
View
@@ -9,12 +9,14 @@
See \code{\link{par}}.}
}
\description{
- A quick and dirty way to show shapes for a palette.
+ A quick and dirty way to show shapes.
}
\examples{
+library(scales)
show_shapes(shape_pal()(5))
}
\seealso{
- \code{\link{show_col}}, \code{\link{show_linetypes}}
+ \code{\link[scales]{show_col}},
+ \code{\link{show_linetypes}}
}
1  man/solarized_pal.Rd
View
@@ -15,6 +15,7 @@
given a primary accent.
}
\examples{
+library(scales)
show_col(solarized_pal()(2))
show_col(solarized_pal()(3))
show_col(solarized_pal("red")(4))
1  man/stata_pal.Rd
View
@@ -13,6 +13,7 @@
schemes: \url{http://www.stata.com/help.cgi?schemes}
}
\examples{
+library(scales)
show_col(stata_pal("s2color")(15))
show_col(stata_pal("s1rcolor")(15))
show_col(stata_pal("s1color")(15))
1  man/tableau_color_pal.Rd
View
@@ -12,6 +12,7 @@
\href{http://www.tableausoftware.com/}{Trableau}.
}
\examples{
+library(scales)
show_col(tableau_color_pal("tableau20")(20))
show_col(tableau_color_pal("tableau10")(10))
show_col(tableau_color_pal("tableau10medium")(10))
20 man/theme_economist.Rd
View
@@ -3,7 +3,7 @@
\title{ggplot color theme based on the Economist}
\usage{
theme_economist(base_size = 12, base_family = "",
- horizontal = TRUE, dkplot = FALSE)
+ horizontal = TRUE, dkpanel = FALSE, stata = FALSE)
}
\arguments{
\item{base_size}{base font size}
@@ -12,17 +12,27 @@
\item{horizontal}{\code{logical}. Horizontal axis lines?}
- \item{dkplot}{\code{logical} Darker background for plot
+ \item{dkpanel}{\code{logical} Darker background for panel
region?}
+
+ \item{stata}{\code{logical} Use RGB values from Stata's
+ economist scheme.}
}
\description{
Style plots similar to those in The Economist.
}
\examples{
dsamp <- diamonds[sample(nrow(diamonds), 1000), ]
-(d <- qplot(carat, price, data=dsamp, colour=clarity)
- + theme_economist()
- + scale_colour_economist() )
+q <- qplot(carat, price, data=dsamp, colour=clarity)
+## Standard
+q + theme_economist() + scale_colour_economist()
+## Stata colors
+q + theme_economist(stata=TRUE) + scale_colour_economist(stata=TRUE)
+## Darker plot region
+q + theme_economist(dkpanel=TRUE) + scale_colour_economist(stata=TRUE)
+## Change axis lines to vertical
+(q + theme_economist(horizontal=FALSE)
+ + scale_colour_economist() + coord_flip())
}
\seealso{
Other themes: \code{\link{theme_excel2003}},
Please sign in to comment.
Something went wrong with that request. Please try again.