Thanks for providing an example. After spending a couple hours going
back and forth between facet wrap and facet grid, I came up with two
things:
1) I think whatever happens happens at build_strip, panel_info, or
layout_grid, maybe with one of these two lines:
row_vars <- unique(.$panel_info[names(.$rows)])
labels[, i] <- labeller(names(label_df)[i], label_df[, i])
But, I do not understand the guts of ggplot2 (/proto?) to be able to
properly debug so I could watch what is happening.
2) It is not on the rows, but you can get a column label using:
ggplot(df.single, aes(x, y)) + geom_line() + facet_wrap(~ a)
HTH,
Josh
P. S. I was also re-impressed with the sheer amount of work and
careful attention to detail Hadley must have put forth to make all of
this. Wow, and thanks.
> --
> You received this message because you are subscribed to the ggplot2 mailing list.
> Please provide a reproducible example: http://gist.github.com/270442
>
> To post: email ggp...@googlegroups.com
> To unsubscribe: email ggplot2+u...@googlegroups.com
> More options: http://groups.google.com/group/ggplot2
>
--
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.com/
FacetGrid$labels_default <- function(., gm, theme) {
labeller <- match.fun(.$labeller[[1]])
add.names <- function(x) {
for(i in 1:ncol(x)) x[[i]] <- labeller(colnames(x)[i], x[,i])
x
}
row.labels <- add.names(rrownames(gm))
col.labels <- add.names(rcolnames(gm))
strip_h <- apply(col.labels, c(2,1), ggstrip, theme = theme)
if (nrow(strip_h) == 1 && ncol(strip_h) == 1) strip_h <-
matrix(list(zeroGrob()))
strip_v <- apply(row.labels, c(1,2), ggstrip, horizontal=FALSE, theme=theme)
# if (nrow(strip_v) == 1 && ncol(strip_v) == 1) strip_v <-
matrix(list(zeroGrob()))
list(
h = strip_h,
v = strip_v
)
}
(p.single <- ggplot( df.single, aes(x, y)) +
geom_line() +
facet_grid(a ~ .)
)
Thanks for your responses,
Matt
--
Seven Deadly Sins (Gandhi):
- Wealth without work - Politics without principle
- Pleasure without conscience - Commerce without morality
- Science without humanity - Worship without sacrifice
- Knowledge without character