【问题标题】:GGally - unexpected behavior with ggpairs(..., diag = list( continuous = 'density'))GGally - ggpairs(..., diag = list( Continuous = 'density')) 的意外行为
【发布时间】:2013-12-03 12:04:51
【问题描述】:

我正在尝试生成一个散点图矩阵,其中对角线具有密度图(最好使用 ggplot)。 GGally 包中ggpairs 的文档说明:

diag 是一个列表,可能只包含变量 'continuous' 和 '离散的'。诊断列表的每个元素都是一个实现 以下选项:连续=恰好是('密度','条形', '空白的');离散的 = ('bar', 'blank') 中的一个。

这表明(??)这应该可以使用diag=list(continuous="density")

但是下面的代码:

xx <- mtcars[,c(1,3,4,6)]   ## extract mpg, disp, hp, and wt from mtcars
library(GGally)
ggpairs(xx,diag=list(continuous="density"))

给出这个:

我做错了什么?

注意:尝试用 plotmatrix(xx) 做同样的事情会得到:

失败是因为密度图显然是使用基于完整数据集 (xx) 的范围在每个对角面中缩放的,而不是基于xx 的范围为适当的面子集。结果,第二行 (disp) 看起来不错,因为 disp 的范围最大,但第 1 行和第 4 行被压缩了。

【问题讨论】:

  • @rcs - 回复:您的编辑。 ggpairs 中 diag 上的 sn-p 是直接从文档中剪切和粘贴的(其中实现拼写错误)。您的编辑看起来并非如此。顺便说一句:你有这个问题的答案吗??

标签: r ggplot2 ggally


【解决方案1】:

所以我终于通过研究另一个问题here 弄清楚了这一点。事实证明,除非将axisLabels 设置为"show",否则对角线上的密度图会被抑制,不会发出警告。

xx <- mtcars[,c(1,3,4,6)]   ## extract mpg, disp, hp, and wt from mtcars
library(GGally)
ggpairs(xx, diag=list(continuous="density"), axisLabels='show')

按预期生成:

【讨论】:

    猜你喜欢
    • 2015-08-31
    • 2015-04-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-05-06
    • 2015-07-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多