Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Use new roxygen features

  • Loading branch information...
commit 726969138600b2e32a6d7c89c6b7f98ec9f23055 1 parent 4be9970
@hadley hadley authored
View
7 R/scale-.r
@@ -22,7 +22,11 @@
#' @S3method print scale
NULL
+#' Continuous scale constructor.
+#'
#' @export
+#' @param aesthetics character
+#' @keywords internal
continuous_scale <- function(aesthetics, scale_name, palette, name = NULL, breaks = NULL, labels = NULL, legend = TRUE, limits = NULL, rescaler = rescale, oob = censor, expand = c(0, 0), na.value = NA, trans = "identity") {
bad_labels <- is.vector(breaks) && is.vector(labels) &&
@@ -58,7 +62,10 @@ continuous_scale <- function(aesthetics, scale_name, palette, name = NULL, break
), class = c(scale_name, "continuous", "scale"))
}
+#' Discrete scale constructor.
+#'
#' @export
+#' @keywords internal
discrete_scale <- function(aesthetics, scale_name, palette, name = NULL, breaks = NULL, labels = NULL, legend = TRUE, limits = NULL, expand = c(0, 0), na.value = NA, drop = TRUE) {
bad_labels <- is.vector(breaks) && is.vector(labels) &&
View
3  R/scale-brewer.r
@@ -2,6 +2,9 @@
#'
#' See \url{http://colorbrewer2.org} for more information.
#'
+#' @inheritParams scales::brewer_pal
+#' @inheritParams scale_colour_hue
+#' @family colour scales
#' @rdname scale_brewer
#' @export
#' @examples
View
2  R/scale-continuous.r
@@ -3,7 +3,7 @@
#' @param ... common continuous scale parameters: \code{name}, \code{breaks},
#' \code{labels}, \code{na.value}, \code{limits} and \code{trans}. See
#' \code{\link{continuous_scale}} for more details
-#' @seealso \code{\link{scale_discrete}} for discrete position scales
+#' @family position scales
#' @rdname scale_continuous
#' @export
#' @examples
View
1  R/scale-date.r
@@ -1,6 +1,7 @@
#' Position scale, date
#'
#' @rdname scale_date
+#' @family position scales
#' @export
#' @examples
#' # We'll start by creating some nonsense data with dates
View
1  R/scale-datetime.r
@@ -1,6 +1,7 @@
#' Position scale, date
#'
#' @rdname scale_datetime
+#' @family position scales
#' @export
#' @examples
#' start <- ISOdate(2001, 1, 1, tz = "")
View
1  R/scale-discrete-.r
@@ -7,6 +7,7 @@
#' at integer positions). This is what allows jittering to work.
#'
#' @rdname scale_discrete
+#' @family position scales
#' @export
#' @examples
#' qplot(cut, data=diamonds, stat="bin")
View
6 R/scale-gradient.r
@@ -1,11 +1,11 @@
#' Smooth gradient between two colours
#'
-#' @param ... Other arguments passed on to \code{\link{continuous_scale}}
-#' to control name, limits, breaks, labels and so forth.
-#' @param na.value Colour to use for missing values
+#' @inheritParams scale_colour_hue
+#' @inheritParams scales::seq_gradient_pal
#' @seealso \code{\link[scales]{seq_gradient_pal}} for details on underlying
#' palette
#' @rdname scale_gradient
+#' @family colour scales
#' @export
#' @examples
#' # It's hard to see, but look for the bright yellow dot
View
5 R/scale-gradient2.r
@@ -1,7 +1,8 @@
#' Diverging colour gradient
#'
-#' @export scale_colour_gradient2 scale_fill_gradient2
-#' @param na.value Colour to use for missing values
+#' @inheritParams scale_colour_hue
+#' @inheritParams scales::div_gradient_pal
+#' @family colour scales
#' @rdname scale_gradient2
#' @export
#' @examples
View
5 R/scale-gradientn.r
@@ -1,7 +1,8 @@
#' Smooth colour gradient between n colours
#'
-#' @export scale_colour_gradientn scale_fill_gradientn
-#' @param na.value Colour to use for missing values
+#' @inheritParams scales::gradient_n_pal
+#' @inheritParams scale_colour_hue
+#' @family colour scales
#' @rdname scale_gradient2
#' @export
#' @examples
View
4 R/scale-grey.r
@@ -2,7 +2,9 @@
#'
#' Based on \code{\link{gray.colors}}
#'
-#' @param na.value Colour to use for missing values
+#' @inheritParams scales::grey_pal
+#' @inheritParams scale_colour_hue
+#' @family colour scales
#' @rdname scale_grey
#' @export
#' @examples
View
4 R/scale-hue.r
@@ -1,8 +1,12 @@
#' Qualitative colour scale with evenly spaced hues.
#'
#' @param na.value Colour to use for missing values
+#' @param ... Other arguments passed on to \code{\link{continuous_scale}}
+#' to control name, limits, breaks, labels and so forth.
+#' @inheritParams scales::hue_pal
#' @rdname scale_hue
#' @export
+#' @family colour scales
#' @examples
#' dsamp <- diamonds[sample(nrow(diamonds), 1000), ]
#' (d <- qplot(carat, price, data=dsamp, colour=clarity))
View
24 man/scale_brewer.Rd
@@ -7,6 +7,18 @@
scale_fill_brewer(..., type = "seq", palette = 1)
}
+\arguments{
+ \item{type}{One of seq (sequential), div (diverging) or
+ qual (qualitative)}
+
+ \item{palette}{If a string, will use that named palette.
+ If a number, will index into the list of palettes of
+ appropriate \code{type}}
+
+ \item{...}{Other arguments passed on to
+ \code{\link{continuous_scale}} to control name, limits,
+ breaks, labels and so forth.}
+}
\description{
See \url{http://colorbrewer2.org} for more information.
}
@@ -34,4 +46,16 @@ ggplot(diamonds, aes(x=price, fill=cut)) +
geom_histogram(position="dodge", binwidth=1000) +
scale_fill_brewer()
}
+\seealso{
+ Other colour scales: \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_gradient}},
+ \code{\link{scale_fill_gradient2}},
+ \code{\link{scale_fill_gradientn}},
+ \code{\link{scale_fill_grey}},
+ \code{\link{scale_fill_hue}}
+}
View
7 man/scale_continuous.Rd
@@ -87,6 +87,11 @@ qplot(rating, votes, data=movies, xlab="My x axis", ylab="My y axis")
qplot(rating, votes, data=movies, log="xy")
}
\seealso{
- \code{\link{scale_discrete}} for discrete position scales
+ Other position scales: \code{\link{scale_x_date}},
+ \code{\link{scale_x_datetime}},
+ \code{\link{scale_x_discrete}},
+ \code{\link{scale_y_date}},
+ \code{\link{scale_y_datetime}},
+ \code{\link{scale_y_discrete}}
}
View
68 man/scale_continuouss.Rd
@@ -1,68 +0,0 @@
-\name{scale_x_continuous}
-\alias{scale_x_continuous}
-\title{Continuous position scales (x & y).}
-\usage{
- scale_x_continuous(..., expand = c(0.05, 0))
-}
-\arguments{
- \item{...}{common continuous scale parameters:
- \code{name}, \code{breaks}, \code{labels},
- \code{na.value}, \code{limits} and \code{trans}. See
- \code{\link{continuous_scale}} for more details}
-}
-\description{
- Continuous position scales (x & y).
-}
-\examples{
-(m <- qplot(rating, votes, data=subset(movies, votes > 1000), na.rm = T))
-
-# Manipulating the default position scales lets you:
-
-# * change the axis labels
-m + scale_y_continuous("number of votes")
-m + scale_y_continuous(expression(votes^alpha))
-
-# * modify the axis limits
-m + scale_y_continuous(limits=c(0, 5000))
-m + scale_y_continuous(limits=c(1000, 10000))
-m + scale_x_continuous(limits=c(7, 8))
-
-# you can also use the short hand functions xlim and ylim
-m + ylim(0, 5000)
-m + ylim(1000, 10000)
-m + xlim(7, 8)
-
-# * choose where the ticks appear
-m + scale_x_continuous(breaks=1:10)
-m + scale_x_continuous(breaks=c(1,3,7,9))
-
-# * manually label the ticks
-m + scale_x_continuous(breaks=c(2,5,8), labels=c("two", "five", "eight"))
-m + scale_x_continuous(breaks=c(2,5,8), labels=c("horrible", "ok", "awesome"))
-m + scale_x_continuous(breaks=c(2,5,8), labels=expression(Alpha, Beta, Omega))
-
-# There are also a wide range of transformations you can use:
-m + scale_y_log10()
-m + scale_y_sqrt()
-m + scale_y_reverse()
-# see ?transformer for a full list
-
-# You can control the formatting of the labels with the formatter
-# argument. Some common formats are built into the scales package:
-x <- rnorm(10) * 100000
-y <- seq(0, 1, length = 10)
-p <- qplot(x, y)
-library(scales)
-p + scale_y_continuous(labels = percent)
-p + scale_y_continuous(labels = dollar)
-p + scale_x_continuous(labels = comma)
-
-# qplot allows you to do some of this with a little less typing:
-# * axis limits
-qplot(rating, votes, data=movies, ylim=c(1e4, 5e4))
-# * axis labels
-qplot(rating, votes, data=movies, xlab="My x axis", ylab="My y axis")
-# * log scaling
-qplot(rating, votes, data=movies, log="xy")
-}
-
View
13 man/scale_date.Rd
@@ -62,4 +62,17 @@ qplot(date, value, data = em, geom = "line", group = variable)
qplot(date, value, data = em, geom = "line", group = variable) +
facet_grid(variable ~ ., scale = "free_y")
}
+\seealso{
+ Other position scales: \code{\link{scale_x_continuous}},
+ \code{\link{scale_x_datetime}},
+ \code{\link{scale_x_discrete}},
+ \code{\link{scale_x_log10}},
+ \code{\link{scale_x_reverse}},
+ \code{\link{scale_x_sqrt}},
+ \code{\link{scale_y_continuous}},
+ \code{\link{scale_y_datetime}},
+ \code{\link{scale_y_discrete}},
+ \code{\link{scale_y_log10}},
+ \code{\link{scale_y_reverse}}, \code{\link{scale_y_sqrt}}
+}
View
13 man/scale_datetime.Rd
@@ -44,4 +44,17 @@ last_plot() + scale_x_datetime(breaks = date_breaks("10 days"))
last_plot() + scale_x_datetime(breaks = date_breaks("10 days"),
labels = date_format("\%d/\%m"))
}
+\seealso{
+ Other position scales: \code{\link{scale_x_continuous}},
+ \code{\link{scale_x_date}},
+ \code{\link{scale_x_discrete}},
+ \code{\link{scale_x_log10}},
+ \code{\link{scale_x_reverse}},
+ \code{\link{scale_x_sqrt}},
+ \code{\link{scale_y_continuous}},
+ \code{\link{scale_y_date}},
+ \code{\link{scale_y_discrete}},
+ \code{\link{scale_y_log10}},
+ \code{\link{scale_y_reverse}}, \code{\link{scale_y_sqrt}}
+}
View
13 man/scale_discrete.Rd
@@ -49,4 +49,17 @@ qplot(reorder(manufacturer, displ), cty, data=mpg)
qplot(reorder(manufacturer, cty), cty, data=mpg) +
scale_x_discrete(labels = abbreviate)
}
+\seealso{
+ Other position scales: \code{\link{scale_x_continuous}},
+ \code{\link{scale_x_date}},
+ \code{\link{scale_x_datetime}},
+ \code{\link{scale_x_log10}},
+ \code{\link{scale_x_reverse}},
+ \code{\link{scale_x_sqrt}},
+ \code{\link{scale_y_continuous}},
+ \code{\link{scale_y_date}},
+ \code{\link{scale_y_datetime}},
+ \code{\link{scale_y_log10}},
+ \code{\link{scale_y_reverse}}, \code{\link{scale_y_sqrt}}
+}
View
18 man/scale_gradient.Rd
@@ -15,6 +15,13 @@
breaks, labels and so forth.}
\item{na.value}{Colour to use for missing values}
+
+ \item{low}{colour for low end of gradient.}
+
+ \item{high}{colour for high end of gradient.}
+
+ \item{space}{colour space in which to calculate gradient.
+ "Lab" usually best unless gradient goes through white.}
}
\description{
Smooth gradient between two colours
@@ -63,5 +70,16 @@ scale_colour_gradient(na.value = "black")
\seealso{
\code{\link[scales]{seq_gradient_pal}} for details on
underlying palette
+
+ Other colour scales: \code{\link{scale_colour_brewer}},
+ \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_gradient2}},
+ \code{\link{scale_fill_gradientn}},
+ \code{\link{scale_fill_grey}},
+ \code{\link{scale_fill_hue}}
}
View
37 man/scale_gradient2.Rd
@@ -20,9 +20,25 @@
"Lab", na.value = "grey50")
}
\arguments{
- \item{na.value}{Colour to use for missing values}
+ \item{...}{Other arguments passed on to
+ \code{\link{continuous_scale}} to control name, limits,
+ breaks, labels and so forth.}
\item{na.value}{Colour to use for missing values}
+
+ \item{low}{colour for low end of gradient.}
+
+ \item{mid}{colour for mid point}
+
+ \item{high}{colour for high end of gradient.}
+
+ \item{space}{colour space in which to calculate gradient.
+ "Lab" usually best unless gradient goes through white.}
+
+ \item{colours}{vector of colours}
+
+ \item{values}{if colours should not be evenly positioned
+ along the gradient}
}
\description{
Diverging colour gradient
@@ -92,4 +108,23 @@ values = values, rescale = function(x, ...) x, oob = identity)
d + scale_colour_gradientn(colours = terrain.colors(10),
values = values, rescale = function(x, ...) x, oob = identity)
}
+\seealso{
+ Other colour scales: \code{\link{scale_colour_brewer}},
+ \code{\link{scale_colour_gradient}},
+ \code{\link{scale_colour_grey}},
+ \code{\link{scale_colour_hue}},
+ \code{\link{scale_fill_brewer}},
+ \code{\link{scale_fill_gradient}},
+ \code{\link{scale_fill_grey}},
+ \code{\link{scale_fill_hue}}
+
+ Other colour scales: \code{\link{scale_colour_brewer}},
+ \code{\link{scale_colour_gradient}},
+ \code{\link{scale_colour_grey}},
+ \code{\link{scale_colour_hue}},
+ \code{\link{scale_fill_brewer}},
+ \code{\link{scale_fill_gradient}},
+ \code{\link{scale_fill_grey}},
+ \code{\link{scale_fill_hue}}
+}
View
20 man/scale_grey.Rd
@@ -10,6 +10,14 @@
"grey50")
}
\arguments{
+ \item{start}{gray value at low end of palette}
+
+ \item{end}{gray value at high end of palette}
+
+ \item{...}{Other arguments passed on to
+ \code{\link{continuous_scale}} to control name, limits,
+ breaks, labels and so forth.}
+
\item{na.value}{Colour to use for missing values}
}
\description{
@@ -29,4 +37,16 @@ qplot(mpg, wt, data = mtcars, colour = miss) + scale_colour_grey()
qplot(mpg, wt, data = mtcars, colour = miss) +
scale_colour_grey(na.value = "green")
}
+\seealso{
+ Other colour scales: \code{\link{scale_colour_brewer}},
+ \code{\link{scale_colour_gradient}},
+ \code{\link{scale_colour_gradient2}},
+ \code{\link{scale_colour_gradientn}},
+ \code{\link{scale_colour_hue}},
+ \code{\link{scale_fill_brewer}},
+ \code{\link{scale_fill_gradient}},
+ \code{\link{scale_fill_gradient2}},
+ \code{\link{scale_fill_gradientn}},
+ \code{\link{scale_fill_hue}}
+}
View
28 man/scale_hue.Rd
@@ -11,6 +11,22 @@
}
\arguments{
\item{na.value}{Colour to use for missing values}
+
+ \item{...}{Other arguments passed on to
+ \code{\link{continuous_scale}} to control name, limits,
+ breaks, labels and so forth.}
+
+ \item{h}{range of hues to use, in [0, 360]}
+
+ \item{c}{chroma (intensity of colour), maximum value
+ varies depending on}
+
+ \item{l}{luminance (lightness), in [0, 100]}
+
+ \item{h.start}{hue to start at}
+
+ \item{direction}{direction to travel around the colour
+ wheel, 1 = clockwise, -1 = counter-clockwise}
}
\description{
Qualitative colour scale with evenly spaced hues.
@@ -49,4 +65,16 @@ qplot(mpg, wt, data = mtcars, colour = miss)
qplot(mpg, wt, data = mtcars, colour = miss) +
scale_colour_hue(na.value = "black")
}
+\seealso{
+ Other colour scales: \code{\link{scale_colour_brewer}},
+ \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_gradient}},
+ \code{\link{scale_fill_gradient2}},
+ \code{\link{scale_fill_gradientn}},
+ \code{\link{scale_fill_grey}}
+}
Please sign in to comment.
Something went wrong with that request. Please try again.