ggpairs rotate axis label [duplicate]

落爺英雄遲暮 提交于 2020-12-08 01:45:51

问题


I have been experimenting with ggpairs (from GGally) as an exploratory tool. I am running into issues with axis tick labels overwriting each other. If this was straight ggplot2, I would put them on a 45 or 90 degree angle and all would be well, but I cannot figure out how to do this for ggpairs. Poking around on the internet leaves me with the feeling that it may be something one can do with wrap, but no idea how to proceed. Can anyone help?

Some code that has an ugly result:

library(dplyr)
library(ggplot2)
library(GGally)
library(MASS)
cars <- dplyr::select(Cars93, Type, Price, MPG.city, MPG.highway, 
                  EngineSize, Origin)
ggpairs(cars)

I get ugly ggpairs with really messy labels in the bottom left corner

Thank you for looking.


回答1:


Since Brian didn't post his comment as an answer, I will. Change the last line to

ggpairs(cars) +
  theme(axis.text.x = element_text(angle = 90, hjust = 1))

and it is all legible.



来源:https://stackoverflow.com/questions/46864196/ggpairs-rotate-axis-label

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!