tidymodels / corrr

Explore correlations in R
https://corrr.tidymodels.org
Other
588 stars 56 forks source link

Overlap x-axis in rplot, can you move labels to vertical #108

Closed mwilson19 closed 4 years ago

mwilson19 commented 4 years ago

Not sure if exists or not, didn't see option but can we rotate the x-axis labels to be vertical so there is not overlap when there are a lot of features? Thanks.

Comes up running titanic data set

library(corrr)
housing_cor <- housing_train %>% 
                  select(where(is.numeric)) %>% 
                  correlate() %>% 
                  rearrange() %>% 
                  shave()
#head(fashion(housing_cor))

rplot(housing_cor, print_cor = TRUE, shape = 20, colors = c(pal[1:2]))
juliasilge commented 4 years ago

The object created by rplot() is a ggplot2 object, so you can act on it in most of the ways you would act on any ggplot2 object, including changing it via calls to theme():

library(corrr)
library(tidyverse)

x <- mtcars %>%
  correlate() %>% 
  focus(-cyl, -vs, mirror = TRUE) %>% 
  rearrange() %>% 
  shave()
#> 
#> Correlation method: 'pearson'
#> Missing treated using: 'pairwise.complete.obs'
#> Registered S3 method overwritten by 'seriation':
#>   method         from 
#>   reorder.hclust gclus

rplot(x)
#> Don't know how to automatically pick scale for object of type noquote. Defaulting to continuous.


rplot(x) +
  theme_gray()
#> Don't know how to automatically pick scale for object of type noquote. Defaulting to continuous.


rplot(x) +
  theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1))
#> Don't know how to automatically pick scale for object of type noquote. Defaulting to continuous.

Created on 2020-07-06 by the reprex package (v0.3.0.9001)

mwilson19 commented 4 years ago

Thank you Julia, you are amazing and have helped me a lot...duh on the above!

juliasilge commented 4 years ago

Oh, it's probably not obvious until you see it in action!

github-actions[bot] commented 3 years ago

This issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue.