小编Sus*_*san的帖子

如何操作 R 中的 ggplot 以在 lhs 上为角度 = 45 长 x 轴标签留出额外空间?

我有几个 geom_bar ggplots,其中我有很长的 x 轴文本名称。如果我以角度 = 90 绘制它们,则图表底部会占用大量空间,因此我尝试使用角度 = 45。这会导致第一个标签的左侧被切断。有没有办法增加左边距?

(不允许发布图片示例)

ggplot(aes(x = cm, y = ahead_aadt),
        data = sbt) + 
   geom_point( ) + geom_line() +
   ggtitle("Ahead AADT Traffic Counts On US 101 in S Santa Barbara Cty") + 
   theme(axis.text.x = element_text(angle=45, size = 9,
     color = "black", face = "plain", vjust = 1, hjust = 1), 
     panel.grid.major.x = element_line(colour = "black", linetype = "dotted")) +
  xlab("Cumulative Mileage") + ylab("Ahead AADT") +
   scale_x_continuous(breaks = sbt$cm,
                      labels =  sbt$description)
Run Code Online (Sandbox Code Playgroud)

r ggplot2

7
推荐指数
2
解决办法
1万
查看次数

标签 统计

ggplot2 ×1

r ×1