Skip to content

Commit e12f8dd

Browse files
committed
Only inherit aesthetics when needed in legend.
Fixes #1267. Can now also set show.legend = NA in rule geoms.
1 parent 8b8369b commit e12f8dd

File tree

5 files changed

+7
-6
lines changed

5 files changed

+7
-6
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
ggplot2 1.0.1.9xxx
22
----------------------------------------------------------------
33

4+
* Legends no longer inherit aesthetics if `inherit.aes` is FALSE (#1267).
5+
46
* The default themes has been tweaked in various minor ways. The legend
57
title and axis titles are now given the same treatment. The default
68
font size has been dropped from 12 to 11. The axes labels are now

R/geom-abline.r

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ NULL
6767
#' geom_point() +
6868
#' geom_hline(aes(yintercept = wt, colour = wt), mean_wt) +
6969
#' facet_wrap(~ cyl)
70-
geom_abline <- function(mapping = NULL, data = NULL, show.legend = FALSE, ...,
70+
geom_abline <- function(mapping = NULL, data = NULL, show.legend = NA, ...,
7171
slope, intercept) {
7272

7373
# If nothing set, default to y = x

R/geom-vline.r

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ NULL
33

44
#' @export
55
#' @rdname geom_abline
6-
geom_vline <- function(mapping = NULL, data = NULL, show.legend = FALSE,
6+
geom_vline <- function(mapping = NULL, data = NULL, show.legend = NA,
77
xintercept, ...) {
88

99
# Act like an annotation

R/guide-legend.r

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ guide_merge.legend <- function(guide, new_guide) {
238238
guide_geom.legend <- function(guide, layers, default_mapping) {
239239
# arrange common data for vertical and horizontal guide
240240
guide$geoms <- plyr::llply(layers, function(layer) {
241-
all <- names(c(layer$mapping, default_mapping, layer$stat$default_aes))
241+
all <- names(c(layer$mapping, if (layer$inherit.aes) default_mapping, layer$stat$default_aes))
242242
geom <- c(layer$geom$required_aes, names(layer$geom$default_aes))
243243
matched <- intersect(intersect(all, geom), names(guide$key))
244244
matched <- setdiff(matched, names(layer$geom_params))

man/geom_abline.Rd

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@
66
\alias{geom_vline}
77
\title{Lines: horizontal, vertical, and specified by slope and intercept.}
88
\usage{
9-
geom_abline(mapping = NULL, data = NULL, show.legend = FALSE, ..., slope,
9+
geom_abline(mapping = NULL, data = NULL, show.legend = NA, ..., slope,
1010
intercept)
1111

1212
geom_hline(mapping = NULL, data = NULL, show.legend = NA, yintercept, ...)
1313

14-
geom_vline(mapping = NULL, data = NULL, show.legend = FALSE, xintercept,
15-
...)
14+
geom_vline(mapping = NULL, data = NULL, show.legend = NA, xintercept, ...)
1615
}
1716
\arguments{
1817
\item{mapping}{The aesthetic mapping, usually constructed with

0 commit comments

Comments
 (0)