更改使用ggplot2创建的堆叠直方图的二进制宽度时出现问题。
它不会出错,但似乎忽略了binwidth设置。
ggplot(trade.a, aes(x=variable1,y=value ,fill=category)) +
geom_bar(stat = "identity", binwidth=c(0,300),position ='fill') +
xlim(0, 300) +
xlab("Variable1") +
ylab("Count") +
ggtitle("Category") +
scale_y_continuous(labels = percent_format()) +
theme_grey(base_size = 20)有什么想法吗?
发布于 2014-02-13 03:17:58
在geom_bar中使用stat="identity"意味着trade.a中的数据已经入库和计数(通过指定指向trade.a数据的y美学也暗示了这一点)。binwidth是stat_bin (geom_bar的默认统计信息)的一个参数,它为您执行聚合。(此外,它只接受一个值;breaks参数可以接受断点的向量。)因此,要更改trade.a数据的装箱宽度,需要返回到执行装箱的步骤。或者从未入库的数据开始,并使用geom_bar的默认stat和指定的binwidth。
https://stackoverflow.com/questions/21735148
复制相似问题