Skip to content

Commit a7842ee

Browse files
committed
add arrow params
1 parent feb39c6 commit a7842ee

File tree

2 files changed

+21
-13
lines changed

2 files changed

+21
-13
lines changed

R/geom-linerange.R

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,18 @@ GeomLinerange <- ggproto(
2727
data
2828
},
2929

30-
draw_panel = function(data, panel_params, coord, lineend = "butt", flipped_aes = FALSE, na.rm = FALSE) {
30+
draw_panel = function(data, panel_params, coord, lineend = "butt",
31+
flipped_aes = FALSE, na.rm = FALSE,
32+
arrow = NULL, arrow.fill = NULL) {
3133
data <- flip_data(data, flipped_aes)
3234
data <- transform(data, xend = x, y = ymin, yend = ymax)
3335
data <- flip_data(data, flipped_aes)
34-
ggname("geom_linerange", GeomSegment$draw_panel(data, panel_params, coord, lineend = lineend, na.rm = na.rm))
36+
grob <- GeomSegment$draw_panel(
37+
data, panel_params, coord,
38+
lineend = lineend, na.rm = na.rm,
39+
arrow = arrow, arrow.fill = arrow.fill
40+
)
41+
ggname("geom_linerange", grob)
3542
},
3643

3744
rename_size = TRUE

R/geom-pointrange.R

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,23 +31,24 @@ GeomPointrange <- ggproto("GeomPointrange", Geom,
3131
},
3232

3333
draw_panel = function(data, panel_params, coord, lineend = "butt", fatten = 4,
34-
flipped_aes = FALSE, na.rm = FALSE) {
34+
flipped_aes = FALSE, na.rm = FALSE,
35+
arrow = NULL, arrow.fill = NULL) {
3536
line_grob <- GeomLinerange$draw_panel(
3637
data, panel_params, coord, lineend = lineend, flipped_aes = flipped_aes,
37-
na.rm = na.rm
38+
na.rm = na.rm, arrow = arrow, arrow.fill = arrow.fill
3839
)
39-
if (is.null(data[[flipped_names(flipped_aes)$y]]))
40+
41+
skip_point <- is.null(data[[flipped_names(flipped_aes)$y]])
42+
if (skip_point) {
4043
return(line_grob)
44+
}
4145

42-
ggname("geom_pointrange",
43-
gTree(children = gList(
44-
line_grob,
45-
GeomPoint$draw_panel(
46-
transform(data, size = size * fatten),
47-
panel_params, coord, na.rm = na.rm
48-
)
49-
))
46+
point_grob <- GeomPoint$draw_panel(
47+
transform(data, size = size * fatten),
48+
panel_params, coord, na.rm = na.rm
5049
)
50+
grob <- gTree(children = gList(line_grob, point_grob))
51+
ggname("geom_pointrange", grob)
5152
}
5253
)
5354

0 commit comments

Comments
 (0)