| scale_discrete {ggplot2} | R Documentation |
Discrete position scale
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, ...)
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 |
This page describes scale_discrete, see layer and qplot for how to create a complete plot from individual components.
A layer
Hadley Wickham, http://had.co.nz/
## 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)