d_geom_segment_mins_maxs: A geom that draws a segment from the minimum x and y to...

Description Usage Arguments Examples

View source: R/d_geom_segment_min_max.R

Description

A geom that draws a segment from the minimum x and y to maximum x and y

Usage

1
2
3
4
5
6
7
8
9
d_geom_segment_mins_maxs(
  mapping = NULL,
  data = NULL,
  position = "identity",
  na.rm = FALSE,
  show.legend = NA,
  inherit.aes = TRUE,
  ...
)

Arguments

...

all the geom_point arguments

Examples

 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)

EvaMaeRey/ggextend documentation built on Dec. 17, 2021, 7:24 p.m.