| geom_step {ggplot2} | R Documentation |
Connect observations by stairs.
geom_step(mapping = NULL, data = NULL, stat = "identity", position = "identity", direction = "hv", ...)
mapping |
The aesthetic mapping, usually constructed with
|
data |
A layer specific dataset - only needed if you want to override the plot defaults. |
stat |
The statistical transformation to use on the data for this layer. |
position |
The position adjustment to use for overlapping points on this layer |
direction |
direction of stairs: 'vh' for vertical then horizontal, or 'hv' for horizontal then vertical |
... |
other arguments passed on to |
geom_step understands the following aesthetics (required aesthetics are in bold):
alpha
colour
linetype
size
# Simple quantiles/ECDF from examples(plot)
x <- sort(rnorm(47))
qplot(seq_along(x), x, geom="step")
# Steps go horizontally, then vertically (default)
qplot(seq_along(x), x, geom="step", direction = "hv")
plot(x, type = "s")
# Steps go vertically, then horizontally
qplot(seq_along(x), x, geom="step", direction = "vh")
plot(x, type = "S")
# Also works with other aesthetics
df <- data.frame(
x = sort(rnorm(50)),
trt = sample(c("a", "b"), 50, rep = TRUE)
)
qplot(seq_along(x), x, data = df, geom="step", colour = trt)