Skip to content

Commit b25b52b

Browse files
committed
Fix weird legend bug
1 parent aebe355 commit b25b52b

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,4 @@ ggplot2 0.8.5 (2009-XX-XX) ----------------------------------------
3636
have formatter argument to match scale_continuous
3737
* legends will only merge if both the title and all labels are the same.
3838
(Fixes #16)
39+
* Fix for bug #19: Legend with three constraints doesn't work

R/guides-legend.r

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ guide_legends <- function(scales, layers, default_mapping, theme) {
7575
} else {
7676
keys <- keys[[1]]
7777
}
78-
7978
build_legend(title, keys, layers, default_mapping, theme)
8079
})
8180
}
@@ -166,7 +165,7 @@ build_legend <- function(name, mapping, layers, default_mapping, theme) {
166165
build_legend_data <- function(layer, mapping, default_mapping) {
167166
all <- names(c(layer$mapping, default_mapping, layer$stat$default_aes()))
168167
geom <- c(layer$geom$required_aes, names(layer$geom$default_aes()))
169-
168+
170169
matched <- intersect(intersect(all, geom), names(mapping))
171170
matched <- setdiff(matched, names(layer$geom_params))
172171

R/layer.r

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,12 @@ Layer <- proto(expr = {
8484
clone <- function(.) as.proto(.$as.list(all.names=TRUE))
8585

8686
use_defaults <- function(., data) {
87-
df <- aesdefaults(data, .$geom$default_aes(), compact(.$mapping))
87+
mapped_vars <- .$mapping[!sapply(.$mapping, is.character)]
88+
df <- aesdefaults(data, .$geom$default_aes(), mapped_vars)
8889

8990
# Override mappings with parameters
9091
gp <- intersect(c(names(df), .$geom$required_aes), names(.$geom_params))
92+
9193
if (length(.$geom_params[gp]))
9294
gp <- gp[sapply(.$geom_params[gp], is.atomic)]
9395
df[gp] <- .$geom_params[gp]

0 commit comments

Comments
 (0)