ggplot 中混合斜体和常规字体的多行文本/标签
Multiple lines of text/ label in mixed italic and regular fonts in ggplot
我尝试了几种方法来将显着性级别作为文本标签添加到图中。我在 ggtext 包中使用 geom_richtext() 得到了结果。虽然标签结果很好,但我将代码粘贴到图形/绘图上。知道如何避免这种情况!或者还有其他选择吗?
geom_richtext(x = 1.15,
y = 0.2,
label.color = "black",
label = "<b>Significance Levels</b><br>ns <i>p</i> > 0.05<br>* <i>p</i> <= 0.05<br>** <i>p</i> <= 0.01<br>*** <i>p</i> <= 0.001<br>**** <i>p</i> <= 0.0001")[enter image description here][1]
试试这个:
library(gridtext)
library(ggplot2)
label <- "<b>Significance Levels</b><br>ns <i>p</i> > 0.05<br>* <i>p</i> <= 0.05<br>** <i>p</i> <= 0.01<br>*** <i>p</i> <= 0.001<br>**** <i>p</i> <= 0.0001"
ggplot(BOD, aes(Time, demand)) +
geom_point() +
annotation_custom(richtext_grob(label), ymin = 0.2)
我尝试了几种方法来将显着性级别作为文本标签添加到图中。我在 ggtext 包中使用 geom_richtext() 得到了结果。虽然标签结果很好,但我将代码粘贴到图形/绘图上。知道如何避免这种情况!或者还有其他选择吗?
geom_richtext(x = 1.15,
y = 0.2,
label.color = "black",
label = "<b>Significance Levels</b><br>ns <i>p</i> > 0.05<br>* <i>p</i> <= 0.05<br>** <i>p</i> <= 0.01<br>*** <i>p</i> <= 0.001<br>**** <i>p</i> <= 0.0001")[enter image description here][1]
试试这个:
library(gridtext)
library(ggplot2)
label <- "<b>Significance Levels</b><br>ns <i>p</i> > 0.05<br>* <i>p</i> <= 0.05<br>** <i>p</i> <= 0.01<br>*** <i>p</i> <= 0.001<br>**** <i>p</i> <= 0.0001"
ggplot(BOD, aes(Time, demand)) +
geom_point() +
annotation_custom(richtext_grob(label), ymin = 0.2)