R ggplot2:更改堆叠直方图宽度的问题

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") +

更改使用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)
有什么想法吗?

geom\u栏中使用
stat=“identity”
意味着
trade.a
中的数据已经被装箱和计数(这也意味着指定了指向
trade.a
数据的
y
美学)
binwidth
是为您进行聚合的
stat\u-bin
(geom\u-bar
的默认统计)的参数。(此外,它只需要一个值;
breaks
参数可以获取断点向量。)因此,要更改
trade.a
数据的装箱宽度,您需要返回到进行装箱的步骤。或者从未绑定的数据开始,使用默认的
stat
作为
geom\u条
,并指定
binwidth