| geom_segment {ggplot2} | R Documentation |
Single line segments
geom_segment(mapping=NULL, data=NULL, stat="identity", position="identity", ...)
mapping |
mapping between variables and aesthetics generated by aes |
data |
dataset used in this layer, if not specified uses plot dataset |
stat |
statistic used by this layer |
position |
position adjustment used by this layer |
... |
other arguments |
This page describes geom_segment, see layer and qplot for how to create a complete plot from individual components.
A layer
The following aesthetics can be used with geom_segment. Aesthetics are mapped to variables in the data with the aes function: geom\_segment(\code{aes}(x = var))
x: x position (required)
y: y position (required)
xend: NULL (required)
yend: NULL (required)
colour: border colour
size: size
linetype: line type
Hadley Wickham, http://had.co.nz/
geom_path: Connect observations, in original order
geom_line: Connect observations, in ordered by x value
## Not run:
require("maps")
xlim <- range(seals$long)
ylim <- range(seals$lat)
usamap <- data.frame(map("world", xlim = xlim, ylim = ylim, plot =
FALSE)[c("x","y")])
usamap <- rbind(usamap, NA, data.frame(map('state', xlim = xlim, ylim
= ylim, plot = FALSE)[c("x","y")]))
names(usamap) <- c("long", "lat")
p <- ggplot(seals, aes(x = long, y = lat))
(p <- p + geom_segment(aes(xend = long + delta_long, yend = lat + delta_lat), arrow=arrow(length=unit(0.1,"cm"))))
p + geom_path(data = usamap) + scale_x_continuous(limits=xlim)
## End(Not run)