Eek*_*orn 7 whitespace r ggplot2
我正在为出版物准备一个人物.我通过设置省略了x标签xlab("")
,但是ggplot2产生一个空格而不是完全删除标签.如何摆脱空白(下图中用红色矩形标记)?
完整代码:
ggplot(data, aes(x=Celltype, y=Mean, fill=factor(Dose), label=p.stars)) +
geom_bar(stat = "identity", position = position_dodge(width=0.9), aes(group=Dose)) +
geom_errorbar(aes(ymin = Mean - SEM, ymax = Mean + SEM), stat = "identity", position = position_dodge(width=0.9), width=0.25) +
geom_text(aes(y = Mean + SEM), size = 5, position = position_dodge(width=0.9), hjust = .5, vjust = -1) +
xlab("") +
ylab("Concentration") +
scale_fill_grey(name = "Dose") +
theme_bw()
Run Code Online (Sandbox Code Playgroud)
你试过plot.margin
吗?
library(grid)
ggplot(data, aes(x=Celltype, y=Mean, fill=factor(Dose), label=p.stars)) +
geom_bar(stat = "identity", position = position_dodge(width=0.9), aes(group=Dose)) +
geom_errorbar(aes(ymin = Mean - SEM, ymax = Mean + SEM), stat = "identity", position = position_dodge(width=0.9), width=0.25) +
geom_text(aes(y = Mean + SEM), size = 5, position = position_dodge(width=0.9), hjust = .5, vjust = -1) +
xlab("") +
ylab("Concentration") +
scale_fill_grey(name = "Dose") +
theme_bw() +
theme(plot.margin = unit(c(1,1,0,1), "cm")) # ("left", "right", "bottom", "top")
Run Code Online (Sandbox Code Playgroud)
使用theme()
删除分配给x轴标题的空间。设置后xlab("")
,仍为该标题留出空间。
+ theme(axis.title.x=element_blank())
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
3633 次 |
最近记录: |