gridtext包——文本渲染包

gridtext包——文本渲染包

这个包可以结合grid包实现在画布上进行文字渲染。

安装

1
devtools::install_github("clauswilke/gridtext")

示例

1
2
3
4
5
6
7
8
9
10
11
library(grid)
library(gridtext)
text1 <- "<span style='font-family:\"Comic Sans MS\"; font-size:20; color:orange'>Comic Sans! Yay!</span>"
text2 <- "Some <span style='color:red'>red</span> text <b>in bold.</b><br>And <i>more</i> text.<br>And some <span style='font-size:18'>large</span> text."
text3 <- "5<i>x</i><sup>2</sup><span style='color:blue'> + 7<i>x</i></span> - <i>α<sub>i</sub></i>"

grid.newpage()
grid.draw(rich_text_grob(text1, x = 0.25, y = 0.9))
grid.draw(rich_text_grob(text2, x = 0.3, y = 0.3, hjust = 0, angle = 45))
grid.draw(rich_text_grob(text2, x = 0.8, y = 0.7, hjust = 1, angle = -90))
grid.draw(rich_text_grob(text3, x = 0.1, y = 0.1))

# R

评论

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×