R 繪圖時(shí)輸出公式

library(dplyr)
p.value <- wilcox.test(x$Normal,x$Cancer)$p.value %>% 
    signif(.,3) %>% as.character() %>% strsplit(.,split = "e-") %>% unlist() %>% as.numeric()
a <- p.value[1]
b <- p.value[2]

ggplot(x,aes(x=Type,y=Value,fill=Type))+
    geom_boxplot()+
    annotate("text",x=1.5,y=6,label = substitute(paste(italic('P value'),"=", a%*%10^b )))+
    labs(x="",y= substitute(paste(log[10],(FTO),+ 5)))+
    theme_bw()+
    theme(
      axis.title = element_text(size=12,face="bold"),
      axis.text = element_text(face="bold",size=12,color = "black"),
      legend.position = ""
    )

如上面代碼所示,為了輸出有上標(biāo)的 p值也是煞費(fèi)苦心,如果有更方便的方式請(qǐng)告知。還實(shí)現(xiàn)了字符串斜體和數(shù)學(xué)公式。

參考

https://blog.csdn.net/weixin_41929524/article/details/88577902
https://blog.csdn.net/weixin_41929524/article/details/103610743
https://blog.csdn.net/songzhilian22/article/details/49487467

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

友情鏈接更多精彩內(nèi)容