數(shù)據(jù)挖掘0308

所有資料來源于生信技能樹

1. 常用的可視化R包

image.png

(1)Base

image.png

image.png

高級函數(shù)是出圖,低級函數(shù)是添磚加瓦

2.ggplot2語法

image.png

入門級模板

ggplot(data = <DATA>) + <GEOM_FUNCTION>(mapping = aes(<MAPPINGS>))

2.1屬性設(shè)置

image.png
geom_point(mapping = aes(x = displ, y = hwy), color = "blue")
ggplot(data = mpg) + 
geom_point(mapping = aes(x = displ, y = hwy), 
size = 5, # 點(diǎn)的大小5mm
alpha = 0.5, # 透明度 50%
shape = "※") # 點(diǎn)的形狀
image.png

2.2映射

image.png
顏色設(shè)置方法

image.png
自行指定映射的顏色

R語言顏色

搜索16禁止顏色代碼,替代下圖中的紅框

image.png
image.png

color是邊框顏色,fill是內(nèi)心顏色

2.3分面

image.png
雙分面

2.4幾何對象

image.png
image.png

image.png

當(dāng)全局變量和局部變量沖突時(shí),以局部變量為主?。。?/p>

ggplot(test,aes(x = Sepal.Length,
                y = Petal.Length,
                color = Species)) +"#color屬于全局變量"
  geom_point()+
  geom_smooth(color = "black")"#color屬于局部變量"
image.png
ggplot(test,aes(x = Sepal.Length,
                y = Petal.Length,
                color = Species)) +"#color為全局變量"
  geom_point()+
  geom_smooth()"#作為局部變量的color已經(jīng)刪除"
image.png

2.5幾何對象

image.png
View(diamonds)
table(diamonds$cut)

ggplot(data = diamonds) + 
  geom_bar(mapping = aes(x = cut))

ggplot(data = diamonds) + 
  stat_count(mapping = aes(x = cut))

image.png

ggplot(data = fre) + geom_bar(mapping = aes(x = Var1, y = Freq), stat = "identity")
image.png

ggplot(data = diamonds) + geom_bar(mapping = aes(x = cut, y = ..prop.., group = 1))

y=..prop..

image.png

2.6位置關(guān)系

(1)

2.7坐標(biāo)系

image.png
完成的繪圖模板
ggplot(data = x, mapping = aes(x = Sepal.Width, y = Species,
                               ),  
       ) + 
  geom_violin(aes(fill=Species))+
  geom_boxplot() +
  geom_jitter(aes(shape=Species))
image.png

3.ggpubr語法

4.圖片的保存和導(dǎo)出

4.1ggsave

image.png

4.2eoffice

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

相關(guān)閱讀更多精彩內(nèi)容

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