R ggplot2:更改堆叠直方图宽度的问题
更改使用ggplot2创建的堆叠直方图的宽度时出现问题 它不会出错,但似乎忽略了binwidth设置R ggplot2:更改堆叠直方图宽度的问题,r,ggplot2,R,Ggplot2,更改使用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") +
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)
有什么想法吗?在geom\u栏中使用stat=“identity”
意味着trade.a
中的数据已经被装箱和计数(这也意味着指定了指向trade.a
数据的y
美学)binwidth
是为您进行聚合的stat\u-bin
(geom\u-bar
的默认统计)的参数。(此外,它只需要一个值;breaks
参数可以获取断点向量。)因此,要更改trade.a
数据的装箱宽度,您需要返回到进行装箱的步骤。或者从未绑定的数据开始,使用默认的stat
作为geom\u条
,并指定binwidth