我的传说中有两行。
如何使一行加粗,颜色为蓝色和大字体,以及一行为小字体,颜色为红色和斜体?

library(ggplot2)
library(gridExtra)
p <- qplot(data = mtcars, wt, mpg)
print(arrangeGrob(p, legend =
  textGrob("large font size colour blue bold\n small font size colour red italic",
           rot = -90, vjust = 1)))

感谢您的帮助。

最佳答案

您需要将文本分成两个textGrob:

library(ggplot2)
library(gridExtra)
p <- qplot(data = mtcars, wt, mpg)
t1 <- textGrob("small font size colour red italic",
               gp = gpar(fontsize = 12, col = 'red', fontface = 'italic'),
               rot = -90, vjust = 1)
t2 <- textGrob("large font size colour blue bold",
               gp = gpar(fontsize = 20, col = 'blue', fontface = 'bold'),
               rot = -90, vjust = 1)
print(arrangeGrob(p, t1, t2, widths = c(9/10, 1/20, 1/20), nrow = 1))

关于r - r ggplot2 : varying font sizes in legend,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/27886766/

10-12 17:35