I could not come up with a nice way to do what you wanted off the top
of my head, but is this acceptable? I know it is not quite what you
asked for...
###############
require(ggplot2)
em <- melt(economics, id = "date")
mylabs <- paste("Y Label", 1:5)
em$variable <- factor(em$variable, labels = mylabs)
qplot(date, value, data = em, geom = "line", group = variable) +
facet_grid(variable ~ ., scale = "free_y") + ylab(NULL)
###############
Best regards,
Josh
> --
> 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/
To place the facet titles on the left side and mimic titles, you could try this,
library(ggplot2)
library(gridExtra)
em <- melt(economics, id = "date")
mylabs <- paste("Y Label", 1:5)
em$variable <- factor(em$variable, labels = mylabs)
p <-
qplot(date, value, data = em, geom = "line", group = variable) +
facet_grid(variable ~ ., scale = "free_y") + ylab(NULL)
labs <- llply(levels(em$variable), textGrob, rot=90)
## add a blank grob "sub" below, as the y title is aligned with the full
## ggplot2 height, not just the panel
my.labels <-
do.call(arrangeGrob,
c(labs, list(ncol=1, left="My y title", sub="")))
## grid.draw(my.labels)
## hack: define the width of my.labels
ylab <- gTree(children=gList(my.labels),
cl="mylabels" )
widthDetails.mylabels <- function(x)
max(stringHeight(levels(em$variable))) + unit(1, "line")
## hack: tweak ggplot2's axis.title.y option to use our gTree
foo <- function()
function(label, x, y) ylab
p + opts(strip.text.y =theme_blank(),
strip.background=theme_blank()) +
opts( axis.title.y = foo())
HTH,
baptiste