相关疑难解决方法(0)

在ggplot2中的栏之间添加空格

亲爱的,我想在ggplot2中的栏之间添加空格.本页提供了一个解决方案:http://www.streamreader.org/stats/questions/6204/how-to-increase-the-space-between-the-bars-in-a-bar-plot-in-ggplot2.但是,此解决方案不是使用x轴分组的因子级别,而是创建一个数字序列x.seq,以手动放置条形,然后使用width()参数对它们进行缩放.但是,当我使用x轴的因子级别分组时,width()不起作用,如下例所示.

library(ggplot2)

Treatment <- rep(c('T','C'),each=2)
Gender <- rep(c('M','F'),2)
Response <- sample(1:100,4)
df <- data.frame(Treatment, Gender, Response)

hist <- ggplot(df, aes(x=Gender, y=Response, fill=Treatment, stat="identity"))
hist + geom_bar(position = "dodge") + scale_y_continuous(limits = c(0, 
    100), name = "") 
Run Code Online (Sandbox Code Playgroud)

有没有人知道如何获得与链接示例中相同的效果,但在使用因子级别分组时?

干杯,

亚伦

r ggplot2

30
推荐指数
1
解决办法
5万
查看次数

标签 统计

ggplot2 ×1

r ×1