首页 > 解决方案 > 在 GMisc 中选择转换图的字体

问题描述

如何更改使用 R 中的 GMisc 包创建的转换图中的文本字体?

我可以得到 2% 的方法如下:

library(grid)
library(Gmisc)

grid.newpage()
txt <-
  "Just a plain box"

windowsFonts(
  A=windowsFont("TT Courier New"),
  B=windowsFont("TT Helvetica"),
  C=windowsFont("TT Montserrat")
)
boxGrob(txt, txt_gp = getOption("boxGrobTxt", default = gpar(fontfamily = "A")))
boxGrob(txt, txt_gp = getOption("boxGrobTxt", default = gpar(fontfamily = "B")))
boxGrob(txt, txt_gp = getOption("boxGrobTxt", default = gpar(fontfamily = "C")))

依次生成三种不同字体的单个框。

我正在寻找一种在渲染像在小插图中创建的过渡图时在全球范围内实现相同目标的方法,即

library(Gmisc)
transitions <- table(data$Charnley_class, data$Charnley_class_1yr) %>%
  getRefClass("Transition")$new(label=c("Before surgery", "1 year after"))
transitions$render()

标签: rr-gridgmisc

解决方案


推荐阅读