How to make a bubble chart with GGally::ggpairs?

I would like to create a bubble chart matrix using GGally::ggpairs .

Defining the point/bubble size in ggplot2 is easy using the size argument:

library("ggplot2")
data(mtcars)
p <- ggplot(mtcars, aes(wt, mpg))
p + geom_point(aes(size = qsec)) 

However, with GGally::ggpairs this does not work. The following code produces this:

library("GGally")
ggpairs(mtcars[ ,c("mpg", "wt", "disp")], 
        size=mtcars$qsec)

显然,在大小= qsec时点没有变化

And the following code does not even produce a plot

ggpairs(mtcars[ ,c("mpg", "wt", "disp")], 
        size="qsec")
> error in eval(expr, envir, enclos) : object 'qsec' not found

Any ideas how to fix this?


You get the last error because qsec is not present in the subset c("mpg", "wt", "disp") .

ggpairs(mtcars[ ,c("mpg", "wt", "disp", "qsec")], columns = 1:3, size = "qsec")

在这里输入图像描述

链接地址: http://www.djcxy.com/p/30914.html

上一篇: 如何在ggpairs中自定义行[GGally]

下一篇: 如何用GGally :: ggpairs制作气泡图?