我需要更改包装的geom_text层中的行距。
library(ggplot2)
library(stringr)
txt = c('one two three', 'four five six', 'seven eight nine')
p = ggplot(data=NULL, aes(x=1:3, y=1:3, label = str_wrap(txt, width = 3))) +
geom_text() + expand_limits(x = c(0.5, 3.5), y = c(0.5, 3.5))
Run Code Online (Sandbox Code Playgroud)
但是theme(text=element_text(lineheight = ...))没有效果,因为它theme仅适用于绘图的非数据组件,因此我不清楚如何实现此目的。有什么建议吗?
只需使用lineheight,例如:
ggplot(data = NULL, aes(x = 1:3, y = 1:3,
label = str_wrap(txt, width = 3))) +
geom_text(lineheight = .5) +
expand_limits(x = c(0.5, 3.5), y = c(0.5, 3.5))
Run Code Online (Sandbox Code Playgroud)
(秒?geom_text)
| 归档时间: |
|
| 查看次数: |
563 次 |
| 最近记录: |