Skip to content

Commit 6dd669b

Browse files
committed
Draw appropriate symbol in crossbar legend. Fixes #768
1 parent d0c46d8 commit 6dd669b

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

R/geom-crossbar.r

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,15 @@ GeomCrossbar <- proto(Geom, {
2929
default_pos <- function(.) PositionIdentity
3030
default_aes = function(.) aes(colour="black", fill=NA, size=0.5, linetype=1, alpha = NA)
3131
required_aes <- c("x", "y", "ymin", "ymax")
32-
guide_geom <- function(.) "path"
32+
guide_geom <- function(.) "crossbar"
33+
draw_legend <- function(., data, ...) {
34+
data <- aesdefaults(data, .$default_aes(), list(...))
35+
gp <- with(data, gpar(col=colour, fill=alpha(fill, alpha), lwd=size * .pt, lty = linetype))
36+
gTree(gp = gp, children = gList(
37+
rectGrob(height=0.5, width=0.75),
38+
linesGrob(c(0.125, 0.875), 0.5)
39+
))
40+
}
3341

3442
draw <- function(., data, scales, coordinates, fatten = 2, width = NULL, ...) {
3543
middle <- transform(data, x = xmin, xend = xmax, yend = y, size = size * fatten, alpha = NA)

0 commit comments

Comments
 (0)