scale expand不会消除bar和axis ggplot之间的差距

时间:2018-02-09 21:49:31

标签: r ggplot2

我有一个如下所示的数据框:

df = data.frame(
  comp_id= c("1A","1A","1A"),
  rate = c(93,93,93),
  quartile = c("25 pctl","50","75 pctl"),
  quartile.value = c(88,92,95)
)

它描绘了一个反对四分位数的点。出于某种原因,我无法消除条和左轴之间的间隙 - 设置笛卡尔不起作用,并且将expand(0,0)添加到scale_y_continuous也不起作用

library(scales)

ggplot(df,
       aes(x = comp_id)) +
  geom_col(aes(y = quartile.value, fill = quartile),
           position = position_dodge(0), width = 2.5) + scale_color_manual(values=c("black"),labels=c("comp_id")) +
  geom_point(aes(y = rate, color="comp_id"), size=3, shape=20) +
  scale_fill_manual(values = c("azure2",  "azure3", "azure4"), labels=c("25th Pctl","Median","75th Pctl")) +
  labs(x="", y="") + scale_y_continuous(limits=c(80,100), oob=rescale_none) + theme(panel.border = element_blank(), panel.background=element_blank()) +
  theme(legend.title=element_blank()) + theme(legend.position="bottom") + scale_x_discrete(expand=c(0,0))

enter image description here

编辑:我使用了scale包,因为当我在y轴上指定限制时,条形消失了。

0 个答案:

没有答案