use ggpairs to create this plot

懵懂的女人 提交于 2019-11-27 04:07:12

Edit for GGally 1.0.1

Since params is now deprecated, use wrap like so:

ggpairs(df[, 1:2], 
        upper = list(continuous = wrap("cor", size = 10)), 
        lower = list(continuous = "smooth"))

Original answer

Customization of complicated plots is not always available through parameter list. That's natural: there are way too many parameters to keep in mind. So the only reliable option is to modify the source. This is especially pleasant when the project is hosted on github.

Here's a simple modification to start with, made in a forked repo. The easiest way to update the code and produce the plot below is to copy and paste the function ggally_cor to your global environment, then override the same function in the GGally namespace:

# ggally_cor <- <...>
assignInNamespace("ggally_cor", ggally_cor, "GGally")
ggpairs(df[, 1:2], 
        upper = list(params = c(size = 10)), 
        lower = list(continuous = "smooth"))

I removed the text label and added significance indicators. Modifying colour and size is not that easy, though, since these are mapped earlier. I'm still thinking on it, but you get the idea and may move on with your further customizations.

Edit: I've updated the code, see my latest commit. It now maps size of the label to the absolute value of the correlation. You can do similar thing if you want different colour, though I think this is probably a not very good idea.

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