在散点图中绘制直方图或饼图

Plot histograms or pie charts in a scatter plot

我需要重复之前做过的事情: tiny pie charts to represent each point in an scatterplot using ggplot2 但我偶然发现了 ggsubplot 包不适用于 3.3.1 R 版本的问题。

基本上我需要散点图上预定义点的直方图或饼图。这是在引用的 post:

中使用的相同代码
foo <- data.frame(X=runif(30),Y=runif(30),A=runif(30),B=runif(30),C=runif(30))
foo.m <- melt(foo, id.vars=c("X","Y"))
ggplot(foo.m, aes(X,Y))+geom_point()
ggplot(foo.m) +
    geom_subplot2d(aes(x = X, y = Y, subplot = geom_bar(aes(variable, 
value, fill = variable), stat = "identity")), width = rel(.5), ref = NULL)

代码使用了库 reshape2、ggplot2 和 ggsubplot。

我想看的图是in the post cited above

UPD:我下载了旧版本的 R(3.0.2 和 3.0.3)和检查点包,并使用了:

checkpoint("2014-09-18")

如以下评论所述。但是我得到一个错误:

Using binwidth 0.0946
Using binwidth 0.0554
Error in layout_base(data, vars, drop = drop) : 
At least one layer must contain all variables used for facetting

我无法解决这个问题,因为当我尝试包含 facet 时,出现以下错误:

Error: ggsubplots do not support facetting

看起来 ggsubplot 不会很快自行修复。一种选择是使用 checkpoint package, and essentially "reset" your copy of R to a time when the package was compatible. This post 建议使用时间点 2014-09-18。