Skip to content

Commit 8f7c348

Browse files
committed
Merge pull request #769 from wch/crossbar-fixes
Fix crossbar legend symbol
2 parents d0c46d8 + fa87c40 commit 8f7c348

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ BUG FIXES
1313
and inherited aesthetic mappings like colour. It no longer does this. (Fixes
1414
#767)
1515

16+
* Plots with geom_crossbar not display correct symbol in legend. (Fixes #768)
17+
1618
ggplot2 0.9.3
1719
----------------------------------------------------------------
1820

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)