本文介绍了GGally - ggpairs的意外行为(...,diag = list(continuous ='density'))的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我试图用对角线中的密度图生成一个散点图矩阵(最好使用ggplot)。 GGally包中的 ggpairs 的文档声明: 这表明(??) diag = list(continuous =density)。 但是下面的代码: xx ggpairs(xx,diag = list(continuous =density)) 给出了这个: 我做错了什么? 注意:试着用 plotmatrix(xx)给出了这个: >)缩放, xx ),而不是基于 xx 为适当的方面进行子集化的范围。因此,第二行(disp)看起来不错,因为disp的范围最大,但第1行和第4行被压缩了。 解决方案 所以我终于明白了这一点,通过研究一个不同的问题这里。事实证明,除非 axisLabels 设置为show,对角线上的密度图会被抑制,而不会有任何警告。 xx library(GGally) ggpairs(xx,diag = list(continuous =density),axisLabels ='show') 如预期的那样产生: I am trying to generate a scatterplot matrix with density plots in the diagonals (using ggplot, preferably). The documentation for ggpairs in the GGally package states:which suggests(??) that this should be possible using diag=list(continuous="density").But the following code:xx <- mtcars[,c(1,3,4,6)] ## extract mpg, disp, hp, and wt from mtcarslibrary(GGally)ggpairs(xx,diag=list(continuous="density"))gives this:What am I doing wrong?NB: Trying to do the same thing with plotmatrix(xx) gives this:which fails because the density plots are, evidently, scaled in each diagonal facet using the range based on the full dataset (xx), rather than the range based on xx subsetted for the appropriate facet. As a result, the second row (disp) looks good because disp has the greatest range, but rows 1 and 4 are crunched. 解决方案 So I finally figured this out, by studying a different question here. It turns out that unless axisLabels is set to "show", density plots on the diagonal are suppressed, without warning.xx <- mtcars[,c(1,3,4,6)] ## extract mpg, disp, hp, and wt from mtcarslibrary(GGally)ggpairs(xx, diag=list(continuous="density"), axisLabels='show')Produces this, as expected: 这篇关于GGally - ggpairs的意外行为(...,diag = list(continuous ='density'))的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
09-05 20:59