12
12
# ' @inheritParams layer
13
13
# ' @inheritParams geom_point
14
14
# ' @param arrow specification for arrow heads, as created by arrow().
15
+ # ' @param arrow.fill fill color to use for the arrow head (if closed). `NULL`
16
+ # ' means use `colour` aesthetic.
15
17
# ' @param lineend Line end style (round, butt, square).
16
18
# ' @param linejoin Line join style (round, mitre, bevel).
17
19
# ' @seealso [geom_path()] and [geom_line()] for multi-
@@ -67,6 +69,7 @@ geom_segment <- function(mapping = NULL, data = NULL,
67
69
stat = " identity" , position = " identity" ,
68
70
... ,
69
71
arrow = NULL ,
72
+ arrow.fill = NULL ,
70
73
lineend = " butt" ,
71
74
linejoin = " round" ,
72
75
na.rm = FALSE ,
@@ -82,6 +85,7 @@ geom_segment <- function(mapping = NULL, data = NULL,
82
85
inherit.aes = inherit.aes ,
83
86
params = list (
84
87
arrow = arrow ,
88
+ arrow.fill = arrow.fill ,
85
89
lineend = lineend ,
86
90
linejoin = linejoin ,
87
91
na.rm = na.rm ,
@@ -99,7 +103,7 @@ GeomSegment <- ggproto("GeomSegment", Geom,
99
103
non_missing_aes = c(" linetype" , " size" , " shape" ),
100
104
default_aes = aes(colour = " black" , size = 0.5 , linetype = 1 , alpha = NA ),
101
105
102
- draw_panel = function (data , panel_params , coord , arrow = NULL ,
106
+ draw_panel = function (data , panel_params , coord , arrow = NULL , arrow.fill = NULL ,
103
107
lineend = " butt" , linejoin = " round" , na.rm = FALSE ) {
104
108
105
109
data <- remove_missing(data , na.rm = na.rm ,
@@ -109,11 +113,12 @@ GeomSegment <- ggproto("GeomSegment", Geom,
109
113
110
114
if (coord $ is_linear()) {
111
115
coord <- coord $ transform(data , panel_params )
116
+ arrow.fill <- arrow.fill %|| % coord $ colour
112
117
return (segmentsGrob(coord $ x , coord $ y , coord $ xend , coord $ yend ,
113
118
default.units = " native" ,
114
119
gp = gpar(
115
120
col = alpha(coord $ colour , coord $ alpha ),
116
- fill = alpha(coord $ colour , coord $ alpha ),
121
+ fill = alpha(arrow.fill , coord $ alpha ),
117
122
lwd = coord $ size * .pt ,
118
123
lty = coord $ linetype ,
119
124
lineend = lineend ,
0 commit comments