我嘗試了幾個選項來將顯著性級別作為文本標簽添加到繪圖中。我在 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]
uj5u.com熱心網友回復:
嘗試這個:
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)

轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/315826.html
