ggobi / ggally

R package that extends ggplot2
http://ggobi.github.io/ggally/
588 stars 118 forks source link

change in axis label/strip styles - any way to revert to previous version? #223

Closed bbolker closed 7 years ago

bbolker commented 7 years ago

I hate to say this, but I find the spiffy new axis label style in ggpairs (or I guess technically this is in ggfacet.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 to ggfacet and passing it through to facet_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 ...

schloerke commented 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')
screen shot 2017-01-16 at 10 35 10 pm screen shot 2017-01-16 at 10 35 38 pm screen shot 2017-01-16 at 10 35 55 pm screen shot 2017-01-16 at 10 36 06 pm
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'")
screen shot 2017-01-16 at 10 37 06 pm screen shot 2017-01-16 at 10 37 23 pm screen shot 2017-01-16 at 10 37 36 pm screen shot 2017-01-16 at 10 38 33 pm
schloerke commented 7 years ago

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.

schloerke commented 7 years ago

@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.

bbolker commented 7 years ago

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 [??])

schloerke commented 7 years ago

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"))
screen shot 2017-01-16 at 11 07 10 pm
schloerke commented 7 years ago

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...?

schloerke commented 7 years ago

I can't think of any case where it would be better to have the label inside the axis ticks.

schloerke commented 7 years ago

@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".

schloerke commented 7 years ago

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"
  )
screen shot 2017-01-16 at 11 39 47 pm
psychelzh commented 1 week ago

How about adding this example to the document of ggpairs()?