删除x轴和x刻度之间的区域

时间:2016-08-01 10:15:53

标签: r graph ggplot2

我想删除x轴和x刻度之间的空格。它将是红色矩形中的区域。 例如

ggplot(mtcars, aes(factor(cyl))) + geom_bar()

我遇到了关于x标签间距的大量信息,但没有看到x标签和x轴之间的距离。

enter image description here

1 个答案:

答案 0 :(得分:0)

只需将scale_y_continuous(expand = c(0,0))添加到ggplot

即可
ggplot(mtcars, aes(factor(cyl))) + geom_bar() + 
  scale_y_continuous(expand = c(0, 0))

Boxplot with removed area between x-axis and plot-area