Description Usage Arguments Details Aesthetics See Also Examples
geom_straw
draws a sloping line between points (x, y) and
(xend, y), where y is an arbitrary height above x and below xend. If x
equals xend then the line is vertical.
1 2 3 |
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, as a string. |
position |
Position adjustment, either as a string, or the result of a call to a position adjustment function. |
na.rm |
If |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
... |
Other arguments passed on to |
This is useful for visualising the difference in time between two events related to one object, e.g. scheduled and actual arrival.
geomsegment
geom_segment
, from which geom_straw
inherits.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | # Plot a subset of the nycflights13 data
library(ggplot2)
ggplot(ggstraw::flights,
aes(sched_dep_time, carrier, xend = dep_time, colour = late)) +
geom_straw() +
scale_colour_manual("Late", values = c("black", "red")) +
xlab("") +
ylab("Carrier") +
ggtitle("Departure times from New York to Boston", sub = "Scheduled vs actual") +
theme_minimal() +
theme(panel.grid = element_blank())
# Plot a subset of the London Underground Metropolitan Line timetable
ggplot(ggstraw::timetable, aes(x = departure, xend = arrival, y = day)) +
geom_straw() +
xlab("") +
ylab("") +
ggtitle("Metropolitan timetable from Harrow-on-the-Hill to Moor Park",
subtitle = "Scheduled departure time (bottom) and scheduled arrival time (top)") +
theme_minimal() +
theme(panel.grid = element_blank())
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.