Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

added scale_dichromat #746

Closed
wants to merge 1 commit into from

2 participants

@jrnold

Added color and fill scales corresponding to for the color-blind dichromat palettes in scales::dichromat_pal, in the same way that scales_*_brewer are defined for scales::brewer_pal.

@hadley
Owner

Could you please rebase/merge against master, re-document with the development version of roxygen2 (install_github("klutometis/roxygen) and resubmit?

@hadley hadley closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 22, 2012
  1. @jrnold
This page is out of date. Refresh to see the latest.
View
1  DESCRIPTION
@@ -205,3 +205,4 @@ Collate:
'translate-qplot-lattice.r'
'annotation-logticks.r'
'utilities-help.r'
+ 'scale-dichromat.r'
View
2  NAMESPACE
@@ -308,6 +308,7 @@ export(scale_color_identity)
export(scale_color_manual)
export(scale_colour_brewer)
export(scale_colour_continuous)
+export(scale_colour_dichromat)
export(scale_colour_discrete)
export(scale_colour_gradient)
export(scale_colour_gradient2)
@@ -318,6 +319,7 @@ export(scale_colour_identity)
export(scale_colour_manual)
export(scale_fill_brewer)
export(scale_fill_continuous)
+export(scale_fill_dichromat)
export(scale_fill_discrete)
export(scale_fill_gradient)
export(scale_fill_gradient2)
View
34 R/scale-dichromat.r
@@ -0,0 +1,34 @@
+#' Dichromat (colour-blind) scales
+#'
+#' Color schemes suitable for deficient or anomalous red-green vision.
+#' See \pkg{dichromat} for more information.
+#'
+#' @inheritParams scales::dichromat_pal
+#' @inheritParams scale_colour_hue
+#' @family colour scales
+#' @rdname scale_dichromat
+#' @export
+#' @examples
+#' dsamp <- diamonds[sample(nrow(diamonds), 1000), ]
+#' (d <- qplot(carat, price, data=dsamp, colour=clarity))
+#' d + scale_colour_dichromat()
+#'
+#' # Select dichromat palette to use, see ?scales::dichromat_pal for more details
+#' d + scale_colour_dichromat(name="BluetoOrange.8")
+#' d + scale_colour_dichromat(name="BluetoGray.8")
+#' d + scale_colour_dichromat(name="Categorical.12")
+#'
+#' # scale_fill_dichromat works just the same as
+#' # scale_colour_dichromat but for fill colours
+#' ggplot(diamonds, aes(x=price, fill=cut)) +
+#' geom_histogram(position="dodge", binwidth=1000) +
+#' scale_fill_dichromat()
+scale_colour_dichromat <- function(..., name="BluetoOrange.10") {
+ discrete_scale("colour", "dichromat", dichromat_pal(name), ...)
+}
+
+#' @export
+#' @rdname scale_dichromat
+scale_fill_dichromat <- function(..., name="BluetoOrange.10") {
+ discrete_scale("fill", "dichromat", dichromat_pal(name), ...)
+}
View
2  man/scale_brewer.Rd
@@ -57,6 +57,7 @@ ggplot(diamonds, aes(x=price, fill=cut)) +
\code{\link{scale_color_grey}},
\code{\link{scale_color_hue}},
\code{\link{scale_colour_continuous}},
+ \code{\link{scale_colour_dichromat}},
\code{\link{scale_colour_discrete}},
\code{\link{scale_colour_gradient}},
\code{\link{scale_colour_gradient2}},
@@ -64,6 +65,7 @@ ggplot(diamonds, aes(x=price, fill=cut)) +
\code{\link{scale_colour_grey}},
\code{\link{scale_colour_hue}},
\code{\link{scale_fill_continuous}},
+ \code{\link{scale_fill_dichromat}},
\code{\link{scale_fill_discrete}},
\code{\link{scale_fill_gradient}},
\code{\link{scale_fill_gradient2}},
View
73 man/scale_dichromat.Rd
@@ -0,0 +1,73 @@
+\name{scale_colour_dichromat}
+\alias{scale_colour_dichromat}
+\alias{scale_fill_dichromat}
+\title{Dichromat (colour-blind) scales}
+\usage{
+ scale_colour_dichromat(..., name = "BluetoOrange.10")
+
+ scale_fill_dichromat(..., name = "BluetoOrange.10")
+}
+\arguments{
+ \item{name}{Name of colour palette. One of:
+ {\code{BrowntoBlue.10}, \code{BrowntoBlue.12},
+ \code{BluetoDarkOrange.12}, \code{BluetoDarkOrange.18},
+ \code{DarkRedtoBlue.12}, \code{DarkRedtoBlue.18},
+ \code{BluetoGreen.14}, \code{BluetoGray.8},
+ \code{BluetoOrangeRed.14}, \code{BluetoOrange.10},
+ \code{BluetoOrange.12}, \code{BluetoOrange.8},
+ \code{LightBluetoDarkBlue.10},
+ \code{LightBluetoDarkBlue.7}, \code{Categorical.12},
+ \code{GreentoMagenta.16}, \code{SteppedSequential.5}}}
+
+ \item{...}{Other arguments passed on to
+ \code{\link{discrete_scale}} to control name, limits,
+ breaks, labels and so forth.}
+}
+\description{
+ Color schemes suitable for deficient or anomalous
+ red-green vision. See \pkg{dichromat} for more
+ information.
+}
+\examples{
+dsamp <- diamonds[sample(nrow(diamonds), 1000), ]
+(d <- qplot(carat, price, data=dsamp, colour=clarity))
+d + scale_colour_dichromat()
+
+# Select dichromat palette to use, see ?scales::dichromat_pal for more details
+d + scale_colour_dichromat(name="BluetoOrange.8")
+d + scale_colour_dichromat(name="BluetoGray.8")
+d + scale_colour_dichromat(name="Categorical.12")
+
+# scale_fill_dichromat works just the same as
+# scale_colour_dichromat but for fill colours
+ggplot(diamonds, aes(x=price, fill=cut)) +
+ geom_histogram(position="dodge", binwidth=1000) +
+ scale_fill_dichromat()
+}
+\seealso{
+ Other colour scales: \code{\link{scale_color_brewer}},
+ \code{\link{scale_color_continuous}},
+ \code{\link{scale_color_discrete}},
+ \code{\link{scale_color_gradient}},
+ \code{\link{scale_color_gradient2}},
+ \code{\link{scale_color_gradientn}},
+ \code{\link{scale_color_grey}},
+ \code{\link{scale_color_hue}},
+ \code{\link{scale_colour_brewer}},
+ \code{\link{scale_colour_continuous}},
+ \code{\link{scale_colour_discrete}},
+ \code{\link{scale_colour_gradient}},
+ \code{\link{scale_colour_gradient2}},
+ \code{\link{scale_colour_gradientn}},
+ \code{\link{scale_colour_grey}},
+ \code{\link{scale_colour_hue}},
+ \code{\link{scale_fill_brewer}},
+ \code{\link{scale_fill_continuous}},
+ \code{\link{scale_fill_discrete}},
+ \code{\link{scale_fill_gradient}},
+ \code{\link{scale_fill_gradient2}},
+ \code{\link{scale_fill_gradientn}},
+ \code{\link{scale_fill_grey}},
+ \code{\link{scale_fill_hue}}
+}
+
View
2  man/scale_gradient.Rd
@@ -110,12 +110,14 @@ qplot(mpg, wt, data = mtcars, colour = miss) +
\code{\link{scale_color_grey}},
\code{\link{scale_color_hue}},
\code{\link{scale_colour_brewer}},
+ \code{\link{scale_colour_dichromat}},
\code{\link{scale_colour_discrete}},
\code{\link{scale_colour_gradient2}},
\code{\link{scale_colour_gradientn}},
\code{\link{scale_colour_grey}},
\code{\link{scale_colour_hue}},
\code{\link{scale_fill_brewer}},
+ \code{\link{scale_fill_dichromat}},
\code{\link{scale_fill_discrete}},
\code{\link{scale_fill_gradient2}},
\code{\link{scale_fill_gradientn}},
View
2  man/scale_gradient2.Rd
@@ -97,6 +97,7 @@ p + scale_fill_gradient2("fill")
\code{\link{scale_color_hue}},
\code{\link{scale_colour_brewer}},
\code{\link{scale_colour_continuous}},
+ \code{\link{scale_colour_dichromat}},
\code{\link{scale_colour_discrete}},
\code{\link{scale_colour_gradient}},
\code{\link{scale_colour_gradientn}},
@@ -104,6 +105,7 @@ p + scale_fill_gradient2("fill")
\code{\link{scale_colour_hue}},
\code{\link{scale_fill_brewer}},
\code{\link{scale_fill_continuous}},
+ \code{\link{scale_fill_dichromat}},
\code{\link{scale_fill_discrete}},
\code{\link{scale_fill_gradient}},
\code{\link{scale_fill_gradientn}},
View
2  man/scale_gradientn.Rd
@@ -78,6 +78,7 @@ d + scale_colour_gradientn(colours = terrain.colors(10),
\code{\link{scale_color_hue}},
\code{\link{scale_colour_brewer}},
\code{\link{scale_colour_continuous}},
+ \code{\link{scale_colour_dichromat}},
\code{\link{scale_colour_discrete}},
\code{\link{scale_colour_gradient}},
\code{\link{scale_colour_gradient2}},
@@ -85,6 +86,7 @@ d + scale_colour_gradientn(colours = terrain.colors(10),
\code{\link{scale_colour_hue}},
\code{\link{scale_fill_brewer}},
\code{\link{scale_fill_continuous}},
+ \code{\link{scale_fill_dichromat}},
\code{\link{scale_fill_discrete}},
\code{\link{scale_fill_gradient}},
\code{\link{scale_fill_gradient2}},
View
2  man/scale_grey.Rd
@@ -51,6 +51,7 @@ qplot(mpg, wt, data = mtcars, colour = miss) +
\code{\link{scale_color_hue}},
\code{\link{scale_colour_brewer}},
\code{\link{scale_colour_continuous}},
+ \code{\link{scale_colour_dichromat}},
\code{\link{scale_colour_discrete}},
\code{\link{scale_colour_gradient}},
\code{\link{scale_colour_gradient2}},
@@ -58,6 +59,7 @@ qplot(mpg, wt, data = mtcars, colour = miss) +
\code{\link{scale_colour_hue}},
\code{\link{scale_fill_brewer}},
\code{\link{scale_fill_continuous}},
+ \code{\link{scale_fill_dichromat}},
\code{\link{scale_fill_discrete}},
\code{\link{scale_fill_gradient}},
\code{\link{scale_fill_gradient2}},
View
2  man/scale_hue.Rd
@@ -96,12 +96,14 @@ qplot(mpg, wt, data = mtcars, colour = miss) +
\code{\link{scale_color_grey}},
\code{\link{scale_colour_brewer}},
\code{\link{scale_colour_continuous}},
+ \code{\link{scale_colour_dichromat}},
\code{\link{scale_colour_gradient}},
\code{\link{scale_colour_gradient2}},
\code{\link{scale_colour_gradientn}},
\code{\link{scale_colour_grey}},
\code{\link{scale_fill_brewer}},
\code{\link{scale_fill_continuous}},
+ \code{\link{scale_fill_dichromat}},
\code{\link{scale_fill_gradient}},
\code{\link{scale_fill_gradient2}},
\code{\link{scale_fill_gradientn}},
Something went wrong with that request. Please try again.