作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我需要更改包裹的 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))
theme(text=element_text(lineheight = ...))
没有效果,因为
theme
仅适用于
non-data components of the plot ,所以我不清楚如何实现这一点。建议?
最佳答案
只需使用 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))
?geom_text
)
关于r - ggplot中换行文本的行距,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51133569/
我是一名优秀的程序员,十分优秀!