R studio界面介紹及par參數詳解


本篇文章主要包含以下內容,其中主要詳細介紹了par參數。其中par參數中的關於圖形位置參數能夠調整圖像位置,達到一張圖中顯示多張圖的效果。
1. R studio 界面
2.par參數
2.1圖形位置參數
2.2顏色設置參數(待更新)
2.3文本參數(待更新)
2.4線條符號相關參數(待更新)
 
1.Rstudio 界面簡介
 
1:R語言編寫區
在這里可以編寫語言,可以刪除,修改。選中你寫的語言,點擊上方run,會在2區看到運行結果
2:運行區
語言的運行結果,出現的錯誤都會在這里展現(不要在這里直接寫語言,因為無法編輯修改)
3:數據顯示區
顯示目前你在R里已經輸入的元素,如數據框,因子等
4:繪圖,求助結果區
export:圖片保存以及保存格式,復制。點擊里面的directory意思是可以選擇保存文件夾
 
1.2 R繪圖界面簡介
R的繪圖界面總共分為三部分:outer margins;figure region;polt region
通常,繪圖窗口中沒有 outer margin。標簽、軸名稱、 圖片標題是在上圖中白色區域,主要的圖形在 plot region,軸和 box 在虛線處。R 中繪圖命令分為兩種:高級——使用的時候會自動生成新窗口;低級——在當前窗口添加。
 
2.par的參數以及實際應用
2.1圖形位置參數
par:是設置全局繪圖參數的函數添加參數no.readonly = TRUE生成一個可修改的當前圖形參數列表
ask: par(ask=TURE),產生新的繪圖頁面之前提示操作
new:par(new=TRUE)新圖在當前的figure region生成。par(new=FALSE),FALSE為默認值,新圖在下一個figure region生成
mfcol:  按照列填充矩陣mfcol=c(3,2):3行2列分割圖形界面(和layout有點像)
mfrow: 按照行填充圖形矩陣
mfg:A numerical vector of the form c(i, j) where i and j indicate which figure in an array of figures is to be drawn next (if setting) or is being drawn (if enquiring). The array must already have been set by mfcol or mfrow.
For compatibility with S, the form c(i, j, nr, nc) is also accepted, when nr and nc should be the current number of rows and number of columns. Mismatches will be ignored, with a warning.
i代表了第幾行;j代表了第幾列,nr,nc代表前面的mfcol或者mfrow
#R 代碼示例
attach(mtcars)
opar<-par(no.readonly = TRUE)
par(mfrow=c(2,2))#圖左
#par(mfclo=c(2,2))圖右
plot(wt,mpg,main = 'Demon1')
plot(wt,disp,main = 'Demon2')
hist(wt,main = 'Demon3')
boxplot(wt,main = 'Demon4')
 
結果示例:
     
#R 代碼示例
#mfg
attach(mtcars)
opar<-par(no.readonly = FALSE)
par(mfcol=c(3,2))#圖區被分成3行2列
plot(wt,mpg,main = 'Demon1')#從默認位置開始
 
par(mfg= c(3, 2,3,2))
plot(wt,disp,main = 'Demon2')
 
par(mfg = c(2, 2,3,2))
hist(wt,main = 'Demon3')
 
par(mfg = c(1, 2,3,2))
boxplot(wt,main = 'Demon4')
 
par(mfg = c(2, 1,3,2))
boxplot(wt,main = 'Demon4')
結果示例:


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM