Hi,
1) I posted a patch on
[aesthetic inheritance and annotation_custom]
(
https://github.com/hadley/ggplot2/issues/756)
see the last message. I reproduce this patch below. As mentioned
there, this patch fixes the issue, and appears to introduce no
regressions that I can see. At least I ran the unit tests and the
visual tests and they gave no errors.
If there are problems with the patch, i.e. code that it breaks, or if
there is some conceptual problem with it, I'd like to know.
NOTE: This code does not work with Winston Chang's example in the issue,
namely
###############################################################################
library(ggplot2)
library(grid)
len = 2
d <- data.frame(r = c( 6.279072, 2.995998, 8.193851, 11.274669),
f1 = c(rep("L", len), rep("H", len)), f2 = rep(c("A", "B"), len))
p3 <- ggplot(data.frame(foo = numeric(0)))
p3 <- p3 + geom_point(data = d, aes(x = f1, y = r, color = f2, group = f2))
p3 = p3 + annotation_custom(circleGrob())library(ggplot2)
library(grid)
len = 2
d <- data.frame(r = c( 6.279072, 2.995998, 8.193851, 11.274669),
f1 = c(rep("L", len), rep("H", len)), f2 = rep(c("A", "B"), len))
p3 <- ggplot(data.frame(foo = numeric(0)))
p3 <- p3 + geom_point(data = d, aes(x = f1, y = r, color = f2, group = f2))
p3 = p3 + annotation_custom(circleGrob())
#################################################################################
It seems there is nothing like this in the test code.
however, this is because the code does not replace the first data set
unless it is a waiver object. Perhaps the solution is also to discard
data frames that contain no data? I'm not sure. If the general
approach is considered acceptable, then the patch would be easy to
modify
Note that it does render, but without the circle.
2) See
[ggplot_gtable creates blank display]
(
https://github.com/hadley/ggplot2/issues/809)
and the Stack Overflow question
[Why does this R ggplot2 code bring up a blank display device?]
(
http://stackoverflow.com/q/17012518/350713)
This looks like something that would be fixable, but I don't
understand enough about what is going on to attempt to do so. Also, it
looks like it probably requires a bunch of fixes in different
locations.
3) See
[multiple calls to annotation_custom fail in certain cases]
(
https://github.com/hadley/ggplot2/issues/817)
and the Stack Overflow question
[calling `str` on a object errors out if the ggplot2 package is loaded]
(
http://stackoverflow.com/q/17127339/350713)
As mentioned therein, the error I was pursuing in the latter part of
this issue looks unlikely to be causing the issue, but is still
something that in my opinion should be fixed.
Regards, Faheem Mitha
## patch for
https://github.com/hadley/ggplot2/issues/756
--- a/R/panel.r
+++ b/R/panel.r
@@ -43,10 +43,18 @@ train_layout <- function(panel, facet, d
# caused problems when they had names of aesthetics (like colour or group).
#
# @param panel a trained panel object
-# @param the facetting specification
+# @param facet the facetting specification
# @param data list of data frames (one for each layer)
# @param plot_data default plot data frame
map_layout <- function(panel, facet, data, plot_data) {
+ ## if plot_data is itself a waiver object, then select the first
+ ## non-waiver element of data as the new default
+ if(is.waive(plot_data))
+ {
+ firstnonwaivepos = match(TRUE, lapply(data, function(x) !is.waive(x)))
+ if(!
is.na(firstnonwaivepos))
+ plot_data = data[[firstnonwaivepos]]
+ }
lapply(data, function(data) {
if (is.waive(data)) data <- plot_data
facet_map_layout(facet, data, panel$layout)