Description Usage Arguments Examples
View source: R/d_geom_segment_min_max.R
A geom that draws a segment from the minimum x and y to maximum x and y
1 2 3 4 5 6 7 8 9 |
... |
all the geom_point arguments |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | # without the function
library(magrittr)
library(dplyr)
cars %>%
summarize(
min_speed = min(speed),
max_speed = max(speed),
min_dist = min(dist),
max_dist = max(dist)
) ->
mins_maxs
library(ggplot2)
ggplot(data = cars) +
aes(x = speed, y = dist) +
geom_point() +
geom_segment(data = mins_maxs,
aes(x = min_speed, xend = max_speed,
y = min_dist, yend = max_dist))
layer_data(last_plot(), i = 2)
# the proto
"StatSegmentminmax"
d_geom_segment_mins_maxs
# using the function
ggplot(data = cars) +
aes(x = speed, y = dist) +
geom_point() +
d_geom_segment_mins_maxs()
layer_data(last_plot(), i = 2)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.