I've been playing with 'ggpairs' a bit and have some questions --
perhaps I'm being a bonehead. If there is a better venue for these
questions (StackOverflow, issues list on github/ggobi/ggally, etc.)
please let me know ...
Here's my basic example:
library(GGally)
d <- diamonds[sample(nrow(diamonds), 100),]
g1 <- ggpairs(d, columns=5:7, colour="color", shape="cut",
lower=list(continuous = "smooth"),
diag=list(continuous="density",discrete="bar"),
axisLabels="none")
This is mostly OK, but:
0. It took me a while to figure out that non-trivial diagonal subplots
are only produced when axisLabels != "internal" (the default); is this
stated/obviously implied from the documentation, or should I submit an
issue suggesting a doc clarification?
1. I would like to remove the space between the subplots. My usual
ggplot2 solution to this is:
library(grid)
zmargin <- theme(panel.margin=unit(0,"lines"))
g1 + zmargin
but this doesn't work in this case (returns NULL). Suggestions?
2. I would like to set the grouping variable to suppress the
group-by-group display of correlations in the upper panels, densities in
the diagonal panels, and smoothing lines in the lower panels. I thought
it might be possible to specify the geoms as (e.g.)
geom_smooth(aes(group=1)) , but I get 'Error in subType != "density" :
comparison (2) is possible only for atomic and list types' -- is there
an obvious way to do this? I also tried this via
params=list(mapping=aes(group=1)) and variations, with no success ..
OK, I see that I can hack this (following
https://groups.google.com/forum/#!topic/ggplot2/O2o8yaOdLmY ) by
defining a special ggally_function within which I add a geom_smooth()
with an altered grouping:
ggally_spoints <- function(data, mapping, ...){
p <- ggplot(data = data, mapping = mapping) + geom_point(...) +
geom_smooth(aes(group=1))
p$type <- "continuous"
p$subType <- "points"
p
}
It should be easy enough to do this with ggally_density as well. I can
do it with ggally_cor, but I'll have to copy a lot more code ...
Are there more ggpairs examples somewhere other than
http://sas-and-r.blogspot.ca/2011/12/example-917-much-better-pairs-plots.html
and
example("ggpairs")
... ?
thanks
Ben Bolker