【发布时间】:2016-10-09 22:16:05
【问题描述】:
我需要重复做的事情: tiny pie charts to represent each point in an scatterplot using ggplot2 但我偶然发现包 ggsubplot 不适用于 3.3.1 R 版本的问题。
基本上我需要散点图上预定义点的直方图或饼图。以下是引用帖子中使用的相同代码:
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
我无法解决,因为当我尝试包含构面时,会出现以下错误:
Error: ggsubplots do not support facetting
【问题讨论】:
标签: r ggplot2 histogram pie-chart scatter-plot