我正在尝试减少长轴标签之间的空间。我基于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()
答案 0 :(得分:11)
您可能正在寻找多种选择。距离class Singleton {
static let sharedInstance: Singleton = {
let instance = Singleton()
// setup code
return instance
}()
}
最近的可能会在lheight
中设置lineheight
。我也把字体缩小了,只是为了显示选项。
element_text
答案 1 :(得分:0)
我遇到了同样的问题,并且找到了一种解决方案,可通过以下方法减少列表:slice(1:40)
library("tidyverse")
df0 <- mtcars %>%
rownames_to_column("car") %>%
mutate(car = str_wrap(car, width = 10)) %>% slice(1:40)
ggplot(data = df0, aes(x = car, y = mpg)) +
geom_bar(stat = "identity") +
coord_flip()
# has no effect
par(lheight = 0.6)
ggplot(data = df0, aes(x = car, y = mpg)) +
geom_bar(stat = "identity") +
coord_flip()
ggplot(data = df0, aes(x = car, y = mpg)) +
geom_bar(stat = "identity") +
coord_flip() +
theme(axis.text.y = element_text(lineheight = 0.6, size = 5))