Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Preserve alpha by default.

Fixes #475.
  • Loading branch information...
commit 84400ad80536fd7858269238aa14d40e7d55eac7 1 parent d012fcd
@hadley authored
View
2  DESCRIPTION
@@ -22,7 +22,7 @@ Imports:
digest,
grid,
reshape2,
- scales (>= 0.2.0.1),
+ scales (>= 0.2.0.2),
memoise,
proto,
MASS
View
3  NEWS
@@ -48,6 +48,9 @@ BUG FIXES
dropped silently, instead of inheriting data from the plot. (Thanks to
Winston Chang. Fixes #31, #332, #506 and #507)
+* The alpha value of set colours is now preserved by default. To return to the
+ old behaviour, set `alpha = 1`. (Fixes #475)
+
ggplot2 0.9.0
----------------------------------------------------------------
View
2  R/geom-abline.r
@@ -82,7 +82,7 @@ GeomAbline <- proto(Geom, {
guide_geom <- function(.) "abline"
default_stat <- function(.) StatAbline
- default_aes <- function(.) aes(colour="black", size=0.5, linetype=1, alpha=1)
+ default_aes <- function(.) aes(colour="black", size=0.5, linetype=1, alpha = NA)
draw_legend <- function(., data, ...) {
data <- aesdefaults(data, .$default_aes(), list(...))
View
2  R/geom-bar-.r
@@ -114,7 +114,7 @@ GeomBar <- proto(Geom, {
default_stat <- function(.) StatBin
default_pos <- function(.) PositionStack
- default_aes <- function(.) aes(colour=NA, fill="grey20", size=0.5, linetype=1, weight = 1, alpha = 1)
+ default_aes <- function(.) aes(colour=NA, fill="grey20", size=0.5, linetype=1, weight = 1, alpha = NA)
required_aes <- c("x")
View
2  R/geom-bin2d.r
@@ -24,7 +24,7 @@ GeomBin2d <- proto(Geom, {
default_stat <- function(.) StatBin2d
required_aes <- c("xmin", "xmax", "ymin", "ymax")
default_aes <- function(.) {
- aes(colour = NA, fill = "grey60", size = 0.5, linetype = 1, weight = 1, , alpha = 1)
+ aes(colour = NA, fill = "grey60", size = 0.5, linetype = 1, weight = 1, , alpha = NA)
}
})
View
8 R/geom-boxplot.r
@@ -128,7 +128,7 @@ GeomBoxplot <- proto(Geom, {
size = data$size,
linetype = data$linetype,
fill = alpha(data$fill, data$alpha),
- group = 1,
+ group = NA,
stringsAsFactors = FALSE
)
@@ -137,7 +137,7 @@ GeomBoxplot <- proto(Geom, {
xend = data$x,
y = c(data$upper, data$lower),
yend = c(data$ymax, data$ymin),
- alpha = 1,
+ alpha = NA,
common)
box <- data.frame(
@@ -160,7 +160,7 @@ GeomBoxplot <- proto(Geom, {
shape = outlier.shape %||% data$shape[1],
size = outlier.size %||% data$size[1],
fill = NA,
- alpha = 1,
+ alpha = NA,
stringsAsFactors = FALSE)
outliers_grob <- GeomPoint$draw(outliers, ...)
} else {
@@ -195,7 +195,7 @@ GeomBoxplot <- proto(Geom, {
default_stat <- function(.) StatBoxplot
default_pos <- function(.) PositionDodge
- default_aes <- function(.) aes(weight=1, colour="grey20", fill="white", size=0.5, alpha = 1, shape = 16, linetype = "solid")
+ default_aes <- function(.) aes(weight=1, colour="grey20", fill="white", size=0.5, alpha = NA, shape = 16, linetype = "solid")
required_aes <- c("x", "lower", "upper", "middle", "ymin", "ymax")
})
View
4 R/geom-crossbar.r
@@ -31,12 +31,12 @@ GeomCrossbar <- proto(Geom, {
default_stat <- function(.) StatIdentity
default_pos <- function(.) PositionIdentity
- default_aes = function(.) aes(colour="black", fill=NA, size=0.5, linetype=1, alpha = 1)
+ default_aes = function(.) aes(colour="black", fill=NA, size=0.5, linetype=1, alpha = NA)
required_aes <- c("x", "y", "ymin", "ymax")
guide_geom <- function(.) "path"
draw <- function(., data, scales, coordinates, fatten = 2, width = NULL, ...) {
- middle <- transform(data, x = xmin, xend = xmax, yend = y, size = size * fatten, alpha = 1)
+ middle <- transform(data, x = xmin, xend = xmax, yend = y, size = size * fatten, alpha = NA)
has_notch <- !is.null(data$ynotchlower) && !is.null(data$ynotchupper) &&
!is.na(data$ynotchlower) && !is.na(data$ynotchupper)
View
2  R/geom-dotplot.r
@@ -271,6 +271,6 @@ GeomDotplot <- proto(Geom, {
default_stat <- function(.) StatBindot
required_aes <- c("x", "y")
- default_aes <- function(.) aes(y=..count.., colour="black", fill = "black", alpha = 1)
+ default_aes <- function(.) aes(y=..count.., colour="black", fill = "black", alpha = NA)
})
View
2  R/geom-error.r
@@ -57,7 +57,7 @@ GeomErrorbar <- proto(Geom, {
}
default_stat <- function(.) StatIdentity
- default_aes <- function(.) aes(colour = "black", size=0.5, linetype=1, width=0.5, alpha = 1)
+ default_aes <- function(.) aes(colour = "black", size=0.5, linetype=1, width=0.5, alpha = NA)
guide_geom <- function(.) "path"
required_aes <- c("x", "ymin", "ymax")
View
2  R/geom-errorh.r
@@ -34,7 +34,7 @@ GeomErrorbarh <- proto(Geom, {
}
default_stat <- function(.) StatIdentity
- default_aes <- function(.) aes(colour = "black", size=0.5, linetype=1, height=0.5, alpha = 1)
+ default_aes <- function(.) aes(colour = "black", size=0.5, linetype=1, height=0.5, alpha = NA)
guide_geom <- function(.) "path"
required_aes <- c("x", "xmin", "xmax")
View
2  R/geom-hex.r
@@ -19,7 +19,7 @@ GeomHex <- proto(Geom, {
}
required_aes <- c("x", "y")
- default_aes <- function(.) aes(colour=NA, fill = "grey50", size=0.5, alpha = 1)
+ default_aes <- function(.) aes(colour=NA, fill = "grey50", size=0.5, alpha = NA)
default_stat <- function(.) StatBinhex
guide_geom <- function(.) "polygon"
View
2  R/geom-hline.r
@@ -63,6 +63,6 @@ GeomHline <- proto(Geom, {
icon <- function(.) linesGrob(c(0, 1), c(0.5, 0.5))
default_stat <- function(.) StatHline
- default_aes <- function(.) aes(colour="black", size=0.5, linetype=1, alpha = 1)
+ default_aes <- function(.) aes(colour="black", size=0.5, linetype=1, alpha = NA)
guide_geom <- function(.) "path"
})
View
2  R/geom-linerange.r
@@ -36,7 +36,7 @@ GeomLinerange <- proto(Geom, {
objname <- "linerange"
default_stat <- function(.) StatIdentity
- default_aes <- function(.) aes(colour = "black", size=0.5, linetype=1, alpha = 1)
+ default_aes <- function(.) aes(colour = "black", size=0.5, linetype=1, alpha = NA)
guide_geom <- function(.) "path"
required_aes <- c("x", "ymin", "ymax")
View
2  R/geom-path-.r
@@ -197,7 +197,7 @@ GeomPath <- proto(Geom, {
default_stat <- function(.) StatIdentity
required_aes <- c("x", "y")
- default_aes <- function(.) aes(colour="black", size=0.5, linetype=1, alpha = 1)
+ default_aes <- function(.) aes(colour="black", size=0.5, linetype=1, alpha = NA)
icon <- function(.) linesGrob(c(0.2, 0.4, 0.8, 0.6, 0.5), c(0.2, 0.7, 0.4, 0.1, 0.5))
guide_geom <- function(.) "path"
View
2  R/geom-path-contour.r
@@ -21,7 +21,7 @@ GeomContour <- proto(GeomPath, {
polygonGrob(c(0.25,0.6,0.8, 0.5), c(0.5, 0.2, 0.75, 0.9), gp=gpar(fill=NA))
)))
}
- default_aes <- function(.) aes(weight=1, colour="#3366FF", size = 0.5, linetype = 1, alpha = 1)
+ default_aes <- function(.) aes(weight=1, colour="#3366FF", size = 0.5, linetype = 1, alpha = NA)
default_stat <- function(.) StatContour
})
View
2  R/geom-path-density2d.r
@@ -22,7 +22,7 @@ GeomDensity2d <- proto(GeomPath, {
objname <- "density2d"
default_stat <- function(.) StatDensity2d
- default_aes <- function(.) aes(weight=1, colour="#3366FF", size = 0.5, linetype = 1, alpha = 1)
+ default_aes <- function(.) aes(weight=1, colour="#3366FF", size = 0.5, linetype = 1, alpha = NA)
icon <- function(.) GeomContour$icon()
})
View
2  R/geom-path-step.r
@@ -40,7 +40,7 @@ GeomStep <- proto(Geom, {
}
details <- "Equivalent to plot(type='s')."
- default_aes <- function(.) aes(colour="black", size=0.5, linetype=1, alpha = 1)
+ default_aes <- function(.) aes(colour="black", size=0.5, linetype=1, alpha = NA)
draw <- function(., data, scales, coordinates, direction = "hv", ...) {
data <- stairstep(data, direction)
View
2  R/geom-point-.r
@@ -154,6 +154,6 @@ GeomPoint <- proto(Geom, {
default_stat <- function(.) StatIdentity
required_aes <- c("x", "y")
- default_aes <- function(.) aes(shape=16, colour="black", size=2, fill = NA, alpha = 1)
+ default_aes <- function(.) aes(shape=16, colour="black", size=2, fill = NA, alpha = NA)
})
View
2  R/geom-pointrange.r
@@ -25,7 +25,7 @@ GeomPointrange <- proto(Geom, {
}
default_stat <- function(.) StatIdentity
- default_aes <- function(.) aes(colour = "black", size=0.5, linetype=1, shape=16, fill=NA, alpha = 1)
+ default_aes <- function(.) aes(colour = "black", size=0.5, linetype=1, shape=16, fill=NA, alpha = NA)
guide_geom <- function(.) "pointrange"
required_aes <- c("x", "y", "ymin", "ymax")
View
2  R/geom-polygon.r
@@ -67,7 +67,7 @@ GeomPolygon <- proto(Geom, {
icon <- function(.) polygonGrob(c(0.1, 0.4, 0.7, 0.9, 0.6, 0.3), c(0.5, 0.8, 0.9, 0.4, 0.2, 0.3), gp=gpar(fill="grey20", col=NA))
default_stat <- function(.) StatIdentity
- default_aes <- function(.) aes(colour="NA", fill="grey20", size=0.5, linetype=1, alpha = 1)
+ default_aes <- function(.) aes(colour="NA", fill="grey20", size=0.5, linetype=1, alpha = NA)
required_aes <- c("x", "y")
guide_geom <- function(.) "polygon"
View
2  R/geom-raster.r
@@ -110,7 +110,7 @@ GeomRaster <- proto(Geom, {
}
default_stat <- function(.) StatIdentity
- default_aes <- function(.) aes(fill = "grey20", alpha = 1)
+ default_aes <- function(.) aes(fill = "grey20", alpha = NA)
required_aes <- c("x", "y")
guide_geom <- function(.) "polygon"
})
View
2  R/geom-rect.r
@@ -18,7 +18,7 @@ GeomRect <- proto(Geom, {
default_stat <- function(.) StatIdentity
default_pos <- function(.) PositionIdentity
- default_aes <- function(.) aes(colour=NA, fill="grey20", size=0.5, linetype=1, alpha = 1)
+ default_aes <- function(.) aes(colour=NA, fill="grey20", size=0.5, linetype=1, alpha = NA)
required_aes <- c("xmin", "xmax", "ymin", "ymax")
View
4 R/geom-ribbon-.r
@@ -48,7 +48,7 @@ GeomRibbon <- proto(Geom, {
objname <- "ribbon"
default_stat <- function(.) StatIdentity
- default_aes <- function(.) aes(colour=NA, fill="grey20", size=0.5, linetype=1, alpha = 1)
+ default_aes <- function(.) aes(colour=NA, fill="grey20", size=0.5, linetype=1, alpha = NA)
required_aes <- c("x", "ymin", "ymax")
guide_geom <- function(.) "polygon"
@@ -121,7 +121,7 @@ na.rm = FALSE, ...) {
GeomArea <- proto(GeomRibbon,{
objname <- "area"
- default_aes <- function(.) aes(colour=NA, fill="grey20", size=0.5, linetype=1, alpha = 1)
+ default_aes <- function(.) aes(colour=NA, fill="grey20", size=0.5, linetype=1, alpha = NA)
default_pos <- function(.) PositionStack
required_aes <- c("x", "y")
View
2  R/geom-ribbon-density.r
@@ -25,5 +25,5 @@ GeomDensity <- proto(GeomArea, {
default_stat <- function(.) StatDensity
default_pos <- function(.) PositionIdentity
- default_aes <- function(.) defaults(aes(fill=NA, weight=1, colour="black", alpha = 1), GeomArea$default_aes())
+ default_aes <- function(.) defaults(aes(fill=NA, weight=1, colour="black", alpha = NA), GeomArea$default_aes())
})
View
2  R/geom-rug.r
@@ -62,6 +62,6 @@ GeomRug <- proto(Geom, {
}
default_stat <- function(.) StatIdentity
- default_aes <- function(.) aes(colour="black", size=0.5, linetype=1, alpha = 1)
+ default_aes <- function(.) aes(colour="black", size=0.5, linetype=1, alpha = NA)
guide_geom <- function(.) "path"
})
View
2  R/geom-segment.r
@@ -70,7 +70,7 @@ GeomSegment <- proto(Geom, {
default_stat <- function(.) StatIdentity
required_aes <- c("x", "y", "xend", "yend")
- default_aes <- function(.) aes(colour="black", size=0.5, linetype=1, alpha = 1)
+ default_aes <- function(.) aes(colour="black", size=0.5, linetype=1, alpha = NA)
guide_geom <- function(.) "path"
})
View
2  R/geom-smooth.r
@@ -37,7 +37,7 @@ GeomSmooth <- proto(Geom, {
draw <- function(., data, scales, coordinates, ...) {
ribbon <- transform(data, colour = NA)
- path <- transform(data, alpha = 1)
+ path <- transform(data, alpha = NA)
has_ribbon <- function(x) !is.null(data$ymax) && !is.null(data$ymin)
View
2  R/geom-text.r
@@ -89,7 +89,7 @@ GeomText <- proto(Geom, {
default_stat <- function(.) StatIdentity
required_aes <- c("x", "y", "label")
default_aes <- function(.) aes(colour="black", size=5 , angle=0, hjust=0.5,
- vjust=0.5, alpha = 1, family="", fontface=1, lineheight=1.2)
+ vjust=0.5, alpha = NA, family="", fontface=1, lineheight=1.2)
guide_geom <- function(x) "text"
})
View
2  R/geom-tile.r
@@ -92,7 +92,7 @@ GeomTile <- proto(Geom, {
}
default_stat <- function(.) StatIdentity
- default_aes <- function(.) aes(fill="grey20", colour=NA, size=0.1, linetype=1, alpha = 1)
+ default_aes <- function(.) aes(fill="grey20", colour=NA, size=0.1, linetype=1, alpha = NA)
required_aes <- c("x", "y")
guide_geom <- function(.) "polygon"
})
View
2  R/geom-violin.r
@@ -116,7 +116,7 @@ GeomViolin <- proto(Geom, {
default_stat <- function(.) StatYdensity
default_pos <- function(.) PositionDodge
- default_aes <- function(.) aes(weight=1, colour="grey20", fill="white", size=0.5, alpha = 1, linetype = "solid")
+ default_aes <- function(.) aes(weight=1, colour="grey20", fill="white", size=0.5, alpha = NA, linetype = "solid")
required_aes <- c("x", "y")
})
View
2  R/geom-vline.r
@@ -67,7 +67,7 @@ GeomVline <- proto(Geom, {
icon <- function(.) linesGrob(c(0.5, 0.5), c(0, 1))
default_stat <- function(.) StatVline
- default_aes <- function(.) aes(colour="black", size=0.5, linetype=1, alpha = 1)
+ default_aes <- function(.) aes(colour="black", size=0.5, linetype=1, alpha = NA)
guide_geom <- function(.) "vline"
draw_legend <- function(., data, ...) {
View
9 visual_test/alpha.r
@@ -0,0 +1,9 @@
+vcontext("Alpha")
+
+qplot(1, 1, color = I("#cc000044"), size = I(50))
+save_vtest("Alpha set in colour")
+
+qplot(1, 1, color = I("#cc0000"), size = I(50), alpha = I(0.27))
+save_vtest("Alpha set in alpha")
+
+end_vcontext()

2 comments on commit 84400ad

@kohske
Collaborator

Does this change break all plots if color is unset? e.g.,

qplot(1:3)
qplot(1:3, 1:3)

I think fill or col of gpar is set as "NA".

And I'd say again that using NA as a flag for something is really bad idea.

@kohske
Collaborator

Ah, work with new scales (0.2.0.3).

Please sign in to comment.
Something went wrong with that request. Please try again.