r語(yǔ)言課程_10高階繪圖_第1頁(yè)
r語(yǔ)言課程_10高階繪圖_第2頁(yè)
r語(yǔ)言課程_10高階繪圖_第3頁(yè)
r語(yǔ)言課程_10高階繪圖_第4頁(yè)
r語(yǔ)言課程_10高階繪圖_第5頁(yè)
已閱讀5頁(yè),還剩33頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、10. R高階繪圖內(nèi)容概要直方圖柱狀圖餅形圖散點(diǎn)圖箱線圖地圖金字塔圖直方圖hist(x, breaks =Sturges, # breaks語(yǔ)句設(shè)定分組數(shù)量 freq = NULL, # 默認(rèn)為頻度輸出,freq=FALSE 為按密度輸出density = NULL, #默認(rèn)沒(méi)有填充,density=20(數(shù)字可改),有填充angle = 45, # 接density語(yǔ)句,填充線的傾斜度,默認(rèn)=45col = NULL, # col設(shè)定顏色,默認(rèn)黑色border = NULL, # border設(shè)定不同顏色main = paste(Histogram of , xname), # main可以

2、自己設(shè)定題目ylim = NULL, #ylim一般默認(rèn),可改變xlab = xname, # xlab設(shè)定自己的labylab, #設(shè)定自己的ylabelaxes = TRUE,# 繪圖默認(rèn)含坐標(biāo)軸) hist(x)hist(x, col = red) hist(leaflife, longev, col = red, xlab = Leaf longevity (yr), main = Leaf longevity histgram) hist(leaflife, longev, col = red, xlab = Leaf longevity (yr), main = Leaf long

3、evity histgram, yaxt = n, border = red)axis(2, las = 2)hist(log10(leaflife, longev),col = red, xlab = Leaf longevity (yr),main = Leaf longevity histgram, axes = F, border = red)axis(2, las = 2)axis(1, at = log10(c(0.5, 1, 2, 4), label = c(0.5, 1, 2, 4)柱狀圖library(sciplot)bargraph.CI(x.factor, respons

4、e,group=NULL, col=NULL, density=NULL, angle=NULL, lc=TRUE, uc=TRUE, legend=FALSE, ncol=1, ylim=NULL, xpd=FALSE, data, .) # 加載sciplot包# x軸上的分類變量# 響應(yīng)變量# 分組變量,默認(rèn)為空# 顏色,可以按分組指定顏色數(shù)量# 柱子中加入其他線條的密度# 柱子中加入其他線條是的角度# 誤差下限 改成FALSE為不顯示誤差下限# 誤差上限,功能同上# 顯示圖例,默認(rèn)不顯示圖例# 圖例顯示的列數(shù)# 設(shè)定ylim# 默認(rèn)文本均在繪圖框里,設(shè)定TRUE可超越# data指定要

5、繪圖的數(shù)據(jù)對(duì)象bargraph.CI(x.factor = rain, response = longev, group = soilp, data = leaflife, legend = T, ylab = Leaf longevity, xlab = Precipitation) bargraph.CI(x.factor = rain, response = longev, group = soilp, data = leaflife, legend = TRUE, ylab = Leaf longevity, xlab = Precipitation, ncol = 1, col =

6、black, angle = c(45, 135), density = 20) 堆棧圖barplot(height, width = 1, space = NULL, horiz = FALSE, density = NULL, angle = 45, col = NULL, xlab = NULL, ylab = NULL, xlim = NULL, ylim = NULL, axes = TRUE, .) #矩陣數(shù)據(jù)#柱子寬度設(shè)置#柱子之間距離#圖形垂直輸出# 填充線條密度# 填充線條角度# 顏色# x標(biāo)示# y標(biāo)示# x軸刻度范圍# y軸刻度范圍# 默認(rèn)顯示坐標(biāo)軸、刻度barplot(

7、dat, ylab = Fraction of explained variance,) barplot(dat, ylab = Fraction of explained variance, border = white, legend = TRUE) barplot(dat, ylab = Fraction of explained variance, border = white, legend = TRUE, xlim = c(0, 8) barplot(dat, xlab = Fraction of explained variance, border = white, horiz

8、= TRUE) f = barplot(dat, xlab = Fraction of explained variance, border = white, horiz = TRUE) 餅形圖pie(x, # x為一維數(shù)組數(shù)據(jù)col = NULL, # 顏色border = NULL, ) # 扇形邊界顏色設(shè)定, 為FALSE效果好pie(large.abund, col = rainbow(length(large.abund) pie2(sort(large.abund), col = rainbow(length(large.abund), border = FALSE, cex =

9、0.8)3D餅圖library(plotrix)# 加載plotrix包pie3D(x,#同餅形圖theta=pi/6,# 視角col=NULL,# 顏色設(shè)定labels=NULL,# 標(biāo)記說(shuō)明labelpos=NULL,# 標(biāo)記位置explode=0,# 扇形裂開(kāi)性shade=0.8,# 陰影.) pie3D(pieval, explode = 0.2, labels = pielabels) 散點(diǎn)圖library(openair)scatterPlot(mydata, x = nox, y = no2, z = NA, method = scatter, type = default, s

10、mooth = FALSE, linear = FALSE, mod.line = FALSE, cols = hue, log.x = FALSE, log.y = FALSE, .) # 加載openair包#數(shù)據(jù)框# 指示x變量#指示y變量# 默認(rèn)z缺失# 方法散點(diǎn)圖# 類型默認(rèn)缺失,可以指定一個(gè)分類變量# 局部平滑# 線性回歸# 擬合線# 散點(diǎn)顏色scatterPlot(mydata = leaflife, x = longev, y = lma, type = rain) scatterPlot(mydata = leaflife, x = longev, y = lma, type

11、 = rain, smooth = TRUE) scatterPlot(mydata = leaflife, x = longev, y = lma, type = rain, linear = TRUE) 箱線圖boxplot(x,x是一個(gè)公式col = NULL, 設(shè)定顏色log = , 對(duì)數(shù)轉(zhuǎn)換horizontal = FALSE, 箱線圖默認(rèn)為垂直顯示) boxplot(longev site, data = leaflife, xlab = site, ylab = Leaf longevity (yr) 箱線圖(ggplot2模式)library(ggplot2)#加載ggplot

12、2包ggplot (data=NULL,#一個(gè)數(shù)據(jù)框格式的數(shù)據(jù)aes(x,# x軸上的分類變量y,# y軸上的分類變量fill)# fill 如果不是x軸上分類變量,雙因素交叉)+geom_boxplot()# 作箱線圖ggplot(leaflife, aes(x = rain, y = longev, fill = rain) + geom_boxplot()ggplot(leaflife, aes(x = rain, y = longev, fill = soilp) + geom_boxplot()地圖-中國(guó)地圖地圖-世界地圖3D圖library(fields)drape.plot(x,

13、 y, z,horizontal = TRUE, theta = 30, phi = 20,.) # 加載fields包# x軸上數(shù)值向量, 為一遞增數(shù)列# y軸數(shù)值向量,同上# z是矩陣,行的長(zhǎng)度同x軸向量長(zhǎng)度,列長(zhǎng)度為y軸向量長(zhǎng)度# 圖例默認(rèn)水平顯示(位于圖的下側(cè))# 延x-y軸水平方向視角# 延z軸水平方向視角drape.plot(x, y, volcano, col = terrain.colors(128), theta = 30, phi = 30)3D繪圖動(dòng)畫(huà)金字塔圖Try it!利用sciplot包中的bargraph.CI函數(shù)針對(duì)leaflife數(shù)據(jù)做site為分組變量的單因

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論