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')
结果示例:

猜你喜欢

转载自www.cnblogs.com/411learn-forever/p/9946421.html
R
R: