【发布时间】:2017-06-26 20:09:58
【问题描述】:
我使用 ggplot 创建了一个条形图。我的数据框:
variable <- c(AFD, AFD, FC, FC, NDT, NDT)
AOI<- c(R,Z,R,Z,R,Z)
mean <- c(219,228,30,130,8381,40164)
se <- c(5,5,1,4,367,1363)
df <- data.frame(variable , AOI, mean, se )
这是我的情节代码:
ggplot(data=Summary_RegBed_ZvsR_Hyp1_lang[Summary_RegBed_ZvsR_Hyp1_lang$variable == "FC", ], aes(x=variable, y=mean, fill=AOI)) +
scale_x_discrete(labels = "Anzahl Fixationen")+
ylab("Absolute Anzahl")+
xlab("Anzahl Fixationen")+
scale_fill_grey(start = 0.35, end= 0.8,
name = "Area of Interest",
breaks=c("R", "Z"),
labels=c("Rand", "Zentrum"))+
geom_bar(stat="identity", position=position_dodge(), width = .6)+
geom_errorbar(aes(ymin=mean-se, ymax=mean+se),
width=.1,
position=position_dodge(.6))+
scale_y_continuous(limit=c(0,140), breaks = c(0,25, 50, 75, 100, 125))+
theme_bw() +
theme(text=element_text(family="Times", face="bold", size=12))+
theme(axis.text.x=element_blank(),
axis.ticks.x=element_blank()) +
geom_signif(annotation="***", y_position=140, xmin=0.85, xmax=1.15, tip_length=0.008)
这是结果图
我的问题是:如何减少条形与 y 轴以及条形与绘图右边缘之间的空间?我需要在彼此旁边绘制几个图,这只是浪费我的空间。 我尝试使用带有中断或限制的 scale_x_discrete ,但都没有奏效。有什么建议么?提前致谢!
【问题讨论】:
-
他们已经挨在一起了,你想怎么缩小空间?
-
对不起,我表达得不好。我不想减少条之间的空间,而是左条和 y 轴之间的空间以及右条和绘图右边缘之间的空间。我想“缩小”x 轴。