Skip to content

Commit

Permalink
Export all scales
Browse files Browse the repository at this point in the history
  • Loading branch information
hadley committed May 16, 2011
1 parent d5461c6 commit 30f634b
Show file tree
Hide file tree
Showing 15 changed files with 56 additions and 11 deletions.
18 changes: 13 additions & 5 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -113,18 +113,26 @@ S3method(scale_breaks, discrete)
S3method(scale_labels, continuous)
S3method(scale_labels, discrete)
export(scale_alpha_continuous)
export(scale_alpha_discrete)
export(scale_area)
export(scale_colour_brewer)
export(scale_colour_brewer, scale_fill_brewer)
export(scale_x_continuous, scale_y_continuous)
S3method(scale_map, position_c)
S3method(scale_clone, position_c)
export(scale_x_date)
export(scale_x_datetime)
export(scale_x_date, scale_y_date)
export(scale_x_datetime, scale_y_datetime)
export(scale_x_discrete, scale_y_discrete)
S3method(scale_train, position_d)
S3method(scale_map, position_d)
S3method(scale_dimension, position_d)
export(scale_colour_gradient)
export(scale_linetype_discrete)
export(scale_colour_gradient, scale_fill_gradient)
export(scale_colour_gradient2, scale_fill_gradient2)
export(scale_colour_gradientn, scale_fill_gradientn)
export(scale_colour_grey, scale_fill_grey)
export(scale_colour_hue, scale_fill_hue)
export(scale_colour_identity, scale_fill_identity, scale_shape_identity, scale_linetype_identity, scale_alpha_identity, scale_size_identity)
export(scale_linetype)
export(scale_colour_manual, scale_fill_manual, scale_shape_manual, scale_linetype_manual, scale_alpha_manual, scale_size_manual)
export(scale_shape)
export(scale_size_continuous)
export(scale_size_discrete)
Expand Down
1 change: 1 addition & 0 deletions R/scale-alpha.r
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ scale_alpha <- scale_alpha_continuous
#'
#' @param ... Other arguments passed on to \code{\link{discrete_scale}}
#' to control name, limits, breaks, labels and so forth.
#' @export
scale_alpha_discrete <- function(..., range = c(1, 6)) {
discrete_scale("alpha", "alpha_d",
function(n) seq(range[1], range[2], length = n), ...)
Expand Down
2 changes: 1 addition & 1 deletion R/scale-brewer.r
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#' @paramCopy palette scales::brewer_pal
#' @usageFor scale_colour_brewer
#' @usageFor scale_fill_brewer
#' @export
#' @export scale_colour_brewer scale_fill_brewer
#' @examples
#' dsamp <- diamonds[sample(nrow(diamonds), 1000), ]
#' (d <- qplot(carat, price, data=dsamp, colour=clarity))
Expand Down
2 changes: 1 addition & 1 deletion R/scale-date.r
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#'
#' @paramCopy ... ggplot2::scale_continuous_x
#' @usageFor scale_continuous_x scale_continuous_y
#' @export
#' @export scale_x_date scale_y_date
#' @examples
#' # We'll start by creating some nonsense data with dates
#' df <- data.frame(
Expand Down
2 changes: 1 addition & 1 deletion R/scale-datetime.r
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#'
#' @paramCopy ... ggplot2::scale_continuous_x
#' @usageFor scale_continuous_x scale_continuous_y
#' @export
#' @export scale_x_datetime scale_y_datetime
#' @examples
#' start <- ISOdate(2001, 1, 1, tz = "")
#' df <- data.frame(
Expand Down
1 change: 1 addition & 0 deletions R/scale-discrete-.r
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#' level, and increasing by one for each level (i.e. the labels are placed
#' at integer positions). This is what allows jittering to work.
#'
#' @export scale_x_discrete scale_y_discrete
#' @examples
#' qplot(cut, data=diamonds, stat="bin")
#' qplot(cut, data=diamonds, geom="bar")
Expand Down
2 changes: 1 addition & 1 deletion R/scale-gradient.r
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#' @usageFor scale_colour_gradient scale_fill_gradient
#' @seealso \code{\link[scales]{seq_gradient_pal}} for details on underlying
#' palette
#' @export
#' @export scale_colour_gradient scale_fill_gradient
#' @examples
#' # It's hard to see, but look for the bright yellow dot
#' # in the bottom right hand corner
Expand Down
1 change: 1 addition & 0 deletions R/scale-gradient2.r
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#' Diverging colour gradient
#'
#' @export scale_colour_gradient2 scale_fill_gradient2
#' @examples
#' dsub <- subset(diamonds, x > 5 & x < 6 & y > 5 & y < 6)
#' dsub$diff <- with(dsub, sqrt(abs(x-y))* sign(x-y))
Expand Down
1 change: 1 addition & 0 deletions R/scale-gradientn.r
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#' Smooth colour gradient between n colours
#'
#' @export scale_colour_gradientn scale_fill_gradientn
#' @examples
#' # scale_colour_gradient make it easy to use existing colour palettes
#'
Expand Down
1 change: 1 addition & 0 deletions R/scale-grey.r
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#'
#' Based on \code{\link{gray.colors}}
#'
#' @export scale_colour_grey scale_fill_grey
#' @examples
#' p <- qplot(mpg, wt, data=mtcars, colour=factor(cyl))
#' p + scale_colour_grey()
Expand Down
1 change: 1 addition & 0 deletions R/scale-hue.r
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#' Qualitative colour scale with evenly spaced hues.
#'
#' @export scale_colour_hue scale_fill_hue
#' @examples
#' dsamp <- diamonds[sample(nrow(diamonds), 1000), ]
#' (d <- qplot(carat, price, data=dsamp, colour=clarity))
Expand Down
2 changes: 2 additions & 0 deletions R/scale-identity.r
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#' Use values without scaling.
#'
#' @export scale_colour_identity scale_fill_identity scale_shape_identity
#' scale_linetype_identity scale_alpha_identity scale_size_identity
#' @examples
#' colour <- c("red", "green", "blue", "yellow")
#' qplot(1:4, 1:4, fill = colour, geom = "tile")
Expand Down
4 changes: 2 additions & 2 deletions R/scale-linetype.r
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
#' qplot(date, value, data=ecm, geom="line", colour=variable)
#'
#' # See scale_manual for more flexibility
scale_linetype_discrete <- function(...) {
scale_linetype <- function(...) {
discrete_scale("linetype", "linetype_d", linetype_pal())
}
scale_linetype_continuous <- function(...) {
stop("A continuous variable can not be mapped to linetype", call. = FALSE)
}
scale_linetype <- scale_linetype_discrete
scale_linetype_discrete <- scale_linetype

icon.linetype <- function(.) {
gTree(children=gList(
Expand Down
5 changes: 5 additions & 0 deletions R/scale-manual.r
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#' Create your own discrete scale.
#'
#' @export scale_colour_manual scale_fill_manual scale_shape_manual
#' scale_linetype_manual scale_alpha_manual scale_size_manual
#' @examples
#' p <- qplot(mpg, wt, data = mtcars, colour = factor(cyl))
#'
Expand Down Expand Up @@ -34,6 +36,9 @@ scale_shape_manual <- function(..., values) {
scale_linetype_manual <- function(..., values) {
discrete_scale("linetype", "manual", manual_pal(values))
}
scale_alpha_manual <- function(..., values) {
discrete_scale("alpha", "manual", manual_pal(values))
}

icon.manual <- function() textGrob("DIY", gp=gpar(cex=1.2))

24 changes: 24 additions & 0 deletions man/scale_linetype.Rd
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
\name{scale_linetype}
\alias{scale_linetype}
\title{Scale for line patterns.}
\usage{scale_linetype(...)}

\description{
Scale for line patterns.
}

\details{
Default line types based on a set supplied by Richard
Pearson, University of Manchester.
}
\examples{ec_scaled <- data.frame(
date = economics$date,
rescaler(economics[, -(1:2)], "range")
)
ecm <- melt(ec_scaled, id = "date")

qplot(date, value, data=ecm, geom="line", group=variable)
qplot(date, value, data=ecm, geom="line", linetype=variable)
qplot(date, value, data=ecm, geom="line", colour=variable)

# See scale_manual for more flexibility}

0 comments on commit 30f634b

Please sign in to comment.