gja*_*bel 4 r line-breaks ggplot2
我想减少长轴标签之间的空间.我基于我应该使用的R图形lheight,但似乎对ggplot没有影响.有ggplot等价吗?
玩具示例显示问题:
library("tidyverse")
df0 <- mtcars %>%
rownames_to_column("car") %>%
mutate(car = str_wrap(car, width = 10))
ggplot(data = df0, aes(x = car, y = mpg)) +
geom_bar(stat = "identity") +
coord_flip()
# has no effect
par(lheight = 0.5)
ggplot(data = df0, aes(x = car, y = mpg)) +
geom_bar(stat = "identity") +
coord_flip()
Run Code Online (Sandbox Code Playgroud)
Mar*_*son 11
您可能正在寻找一系列选项.最接近lheight的可能设置lineheight在element_text.我也把字体缩小了,只是为了显示选项.
ggplot(data = df0, aes(x = car, y = mpg)) +
geom_bar(stat = "identity") +
coord_flip() +
theme(axis.text.y = element_text(lineheight = 0.5
, size = 6))
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3954 次 |
| 最近记录: |