geom_leg | R Documentation |
This is ggplot2's segment with rounded ends. It's mainly included in ggmap for historical reasons.
geom_leg(
mapping = NULL,
data = NULL,
stat = "identity",
position = "identity",
arrow = NULL,
lineend = "round",
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE,
...
)
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
stat |
The statistical transformation to use on the data for this
layer, either as a |
position |
Position adjustment, either as a string naming the adjustment
(e.g. |
arrow |
specification for arrow heads, as created by |
lineend |
Line end style (round, butt, square). |
na.rm |
If |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
... |
Other arguments passed on to |
only intended for use in ggmap package. only designed for mercator projection.
geom_segment()
, route()
, inspired by
http://spatialanalysis.co.uk/2012/02/great-maps-ggplot2/, no longer active
## Not run: # removed for R CMD check speed
map <- get_map(
location = c(-77.0425, 38.8925), # painfully picked by hand
source = "google", zoom = 14, maptype = "satellite"
)
ggmap(map)
(legs_df <- route(
"the white house, dc",
"lincoln memorial washington dc",
alternatives = TRUE
))
ggplot(data = legs_df) +
geom_leg(aes(
x = start_lon, xend = end_lon,
y = start_lat, yend = end_lat
)) +
coord_map()
ggplot(data = legs_df) +
geom_leg(aes(
x = start_lon, xend = end_lon,
y = start_lat, yend = end_lat,
color = route
)) +
coord_map()
ggmap(map) +
geom_leg(
aes(
x = start_lon, xend = end_lon,
y = start_lat, yend = end_lat
),
data = legs_df, color = "red"
)
# adding a color aesthetic errors because of a base-layer problem
# ggmap(map) +
# geom_leg(
# aes(
# x = start_lon, xend = end_lon,
# y = start_lat, yend = end_lat,
# color = route
# )
# )
# this is probably the easiest hack to fix it
ggplot(data = legs_df) +
inset_ggmap(map) +
geom_leg(
aes(
x = start_lon, xend = end_lon,
y = start_lat, yend = end_lat,
color = route
),
data = legs_df
) +
coord_map()
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.