Skip to content

Commit e3bd311

Browse files
committed
Revert #1371. Alpha affects only fill.
Fixes #1523
1 parent 6f04b85 commit e3bd311

File tree

5 files changed

+25
-3
lines changed

5 files changed

+25
-3
lines changed

NEWS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# ggplot2 2.0.0.9000
22

3+
* For geoms with both `colour` and `fill`, `alpha` once again only affects
4+
fill (Reverts #1371, #1523). This was causing problems for people.
5+
36
* `geom_path()` knows that "solid" (not just 1) represents a solid line (#1534).
47

58
* `layer()` now automatically adds a `na.rm` parameter if none is explicitly

R/geom-polygon.r

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ GeomPolygon <- ggproto("GeomPolygon", Geom,
9191
polygonGrob(munched$x, munched$y, default.units = "native",
9292
id = munched$group,
9393
gp = gpar(
94-
col = alpha(first_rows$colour, first_rows$alpha),
94+
col = first_rows$colour,
9595
fill = alpha(first_rows$fill, first_rows$alpha),
9696
lwd = first_rows$size * .pt,
9797
lty = first_rows$linetype

R/geom-rect.r

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ GeomRect <- ggproto("GeomRect", Geom,
5555
default.units = "native",
5656
just = c("left", "top"),
5757
gp = gpar(
58-
col = alpha(coords$colour, coords$alpha),
58+
col = coords$colour,
5959
fill = alpha(coords$fill, coords$alpha),
6060
lwd = coords$size * .pt,
6161
lty = coords$linetype,

R/geom-ribbon.r

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ GeomRibbon <- ggproto("GeomRibbon", Geom,
9696
default.units = "native",
9797
gp = gpar(
9898
fill = alpha(aes$fill, aes$alpha),
99-
col = alpha(aes$colour, aes$alpha),
99+
col = aes$colour,
100100
lwd = aes$size * .pt,
101101
lty = aes$linetype)
102102
))

tests/testthat/test-aes-setting.r

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,22 @@ test_that("Aesthetic parameters must match length of data", {
1515
set_colours(rep("red", 5))
1616

1717
})
18+
19+
test_that("alpha affects only fill colour of solid geoms", {
20+
df <- data.frame(x = 1:2, y = 1)
21+
22+
poly <- ggplot(df, aes(x = x, y)) +
23+
geom_polygon(fill = "red", colour = "red", alpha = 0.5)
24+
rect <- ggplot(df, aes(xmin = x, xmax = x + 1, ymin = 1, ymax = y + 1)) +
25+
geom_rect(fill = "red", colour = "red", alpha = 0.5)
26+
ribb <- ggplot(df, aes(x = x, ymin = 1, ymax = y + 1)) +
27+
geom_ribbon(fill = "red", colour = "red", alpha = 0.5)
28+
29+
expect_equal(layer_grob(poly)[[1]]$gp$col[[1]], "red")
30+
expect_equal(layer_grob(rect)[[1]]$gp$col[[1]], "red")
31+
expect_equal(layer_grob(ribb)[[1]]$children[[1]]$gp$col[[1]], "red")
32+
33+
expect_equal(layer_grob(poly)[[1]]$gp$fill[[1]], "#FF000080")
34+
expect_equal(layer_grob(rect)[[1]]$gp$fill[[1]], "#FF000080")
35+
expect_equal(layer_grob(ribb)[[1]]$children[[1]]$gp$fill[[1]], "#FF000080")
36+
})

0 commit comments

Comments
 (0)