采用ggplot2繪制誤差線需要對(duì)數(shù)據(jù)轉(zhuǎn)換求得mean和sd(或se等),可以通過superb包superbPlot函數(shù)一步到位法,下面以ToothGrowth數(shù)據(jù)集進(jìn)行演示,ToothGrowth數(shù)據(jù)為維生素C對(duì)60只豚鼠牙齒生長影響的實(shí)驗(yàn)結(jié)果,其中supp指給藥方法,dose指給藥劑量,len指牙齒生長的長度。
superbPlot(ToothGrowth,
? ? ? ? ? BSFactors = c("dose", "supp"),
? ? ? ? ? variables = "len",
? ? ? ? ? plotStyle = "raincloud")

superbPlot(ToothGrowth,
? ? ? ? ? BSFactors = c("dose", "supp"),
? ? ? ? ? variables = "len")

superbPlot(ToothGrowth,
? ? ? ? ? BSFactors = c("dose", "supp"),
? ? ? ? ? variables = "len",
? ? ? ? ? plotStyle = "line")

最后設(shè)置主題,可以直接使用ggplot的主題,如下:
superbPlot(ToothGrowth, BSFactors = c("dose", "supp"),? ?variables = "len", plotStyle = "raincloud")? +theme_classic()+? theme(axis.text =element_text(colour = "black"), title = element_text(colour = "black",face = "bold"), text = element_text(family = "serif"), legend.title? = element_blank(),legend.text = element_text(colour = "black",face = "bold"), legend.position = "bottom" ,legend.box = "horizontal")
本文僅供學(xué)習(xí)交流所用,均來源于網(wǎng)絡(luò)及日常用到內(nèi)容摘錄或記錄。部分資料來源網(wǎng)絡(luò),可能疏忽未注明來源,如果原作者有疑義或者認(rèn)為侵犯了版權(quán),請盡快聯(lián)系本人,將盡快刪除,部分資料和理解來自個(gè)人整理,請謹(jǐn)慎使用,本人不保證所有代碼在各個(gè)平臺(tái)上的通用性,也不保證兼容性.如果您對(duì)本文有什么意見,歡迎與我聯(lián)系
1. superb幫助文件