scale_discrete {ggplot2}R Documentation

scale_discrete

Description

Discrete position scale

Usage

scale_x_discrete(name=NULL, expand=c(0.05, 0), limits=NULL, breaks=NULL, labels=NULL, ...)
scale_y_discrete(name=NULL, expand=c(0.05, 0), limits=NULL, breaks=NULL, labels=NULL, ...)
scale_z_discrete(name=NULL, expand=c(0.05, 0), limits=NULL, breaks=NULL, labels=NULL, ...)

Arguments

name name of scale to appear in legend or on axis
expand numeric vector of length 2, giving multiplicative and additive expansion factors
limits numeric vector of length 2, giving the extent of the scale
breaks numeric vector indicating where breaks should lie
labels character vector giving labels associated with breaks
... ignored

Details

This page describes scale_discrete, see layer and qplot for how to create a complete plot from individual components.

Value

A layer

Author(s)

Hadley Wickham, http://had.co.nz/

See Also

Examples

## Not run: 
# The discrete position scale is added automatically whenever you
# have a discrete position and the only thing you can do with it
# is change the labels

(d <- qplot(cut, clarity, data=subset(diamonds, carat > 1), geom="jitter"))

d + scale_x_discrete("Cut")
d + scale_x_discrete("Cut", labels=c("F","G","VG","P","I"))

d + scale_y_discrete("Clarity")
d + scale_x_discrete("Cut") + scale_y_discrete("Clarity")

# Use limits to adjust the which levels (and in what order)
# are displayed
d + scale_x_discrete(limits=c("Fair","Ideal"))
# See ?reorder to reorder based on the values of another variable

## End(Not run)

[Package ggplot2 version 0.7 Index]