Closed bbolker closed 7 years ago
How does this work for interface? I am including the four plots with a regular ggplot2 facet_grid for comparison
devtools::install_github("ggobi/ggally@ggfacet_params")
library(GGally)
library(ggplot2)
data(tips, package = "reshape")
qplot(total_bill, tip, data = tips, main = "qplot + facet_grid; default; switch = NULL") + facet_grid(sex ~ day, switch = NULL)
qplot(total_bill, tip, data = tips, main = "qplot + facet_grid; switch = 'x'") + facet_grid(sex ~ day, switch = 'x')
qplot(total_bill, tip, data = tips, main = "qplot + facet_grid; switch = 'y'") + facet_grid(sex ~ day, switch = 'y')
qplot(total_bill, tip, data = tips, main = "qplot + facet_grid; switch = 'both'") + facet_grid(sex ~ day, switch = 'both')
ggpairs(tips, c(1,3,2), mapping = aes(color = sex), switch = NULL, title = "ggpairs; default; switch = NULL")
ggpairs(tips, c(1,3,2), mapping = aes(color = sex), switch = 'x', title = "ggpairs; default; switch = 'x'")
ggpairs(tips, c(1,3,2), mapping = aes(color = sex), switch = 'y', title = "ggpairs; default; switch = 'y'")
ggpairs(tips, c(1,3,2), mapping = aes(color = sex), switch = 'both', title = "ggpairs; default; switch = 'both'")
Looking at the other variables in ggplot2::facet_grid, they don't make sense for the ggmatrix being produced. I added the switch param to ggmatrix, ggpairs, and ggduo.
@bbolker Downgrading is no fun as there are a lot of ggplot2 dependencies that would have to be downgraded as well. Hopefully we can get a solution here.
this is amazing response time, and certainly an improvement. Do you think there's a way to hack/trick ggpairs into making the strip labels look like proper axis labels (i.e. no gray background [probably easy], plotted outside (below/to left of) axis tick labels rather than inside [??])
At this point, it's a ggplot2 object. So we can add themes to make the strip change colors.
library(ggplot2)
data(tips, package = "reshape")
pm <- load_all(); ggpairs(tips, c(1,3,2), mapping = aes(color = sex), switch = "both")
pm + theme(strip.background = element_rect(fill = "white"))
As for the order of display, that's a ggplot2 issue? I don't know how to do this with ggplot2 natively
Or should GGally do this automatically with no option to change...?
I can't think of any case where it would be better to have the label inside the axis ticks.
@bbolker Can you think of any reason why we shouldn't do switch the position? If so, I'll add it in.
Also, the param name might change as ggplot2 is moving from "switch" (v2.1.0) to "strip.position" (v2.2.0). I may end up using "label_position".
Ha! I got it. I'll add this in as an example somewhere. For now I am going to close the issue. 😄
ggpairs(tips, c(1,3,2), mapping = aes(color = sex), switch = "both") +
theme(
strip.background = element_rect(fill = "white"),
strip.placement = "outside"
)
How about adding this example to the document of ggpairs()
?
I hate to say this, but I find the spiffy new axis label style in
ggpairs
(or I guess technically this is inggfacet.R
) disappointing relative to the old style. I definitely prefer the old style, as seen e.g. in this SO question ...Having strip labels on bottom/left is most important to me. I think it might be possible to achieve this by adding a
switch
argument toggfacet
and passing it through tofacet_grid
(and allowing it to be set/passed through from upstream) ... ideally, the labels would look more like regular axis labels, but that might be manageable my modifying the strip characteristics ... ?I will work on this, but thought I would post it before I dug in, in case you are already working on this or have useful ideas (or want to jump in and solve the problem for me ...)
In the meantime I may 'solve' the problem by reverting to an earlier version of
ggpairs
...