在R语言中, 绘图边框一共有3个区域:

device region :

figure region :

plot region   :

在描述不同区域大小的时候,有对应的不同参数:

din : 返回device region 的宽度和高度, 单位为 inches

fin : 返回figure region 的宽度和高度,单位为 inches

pin : 返回plot region 的宽度和高度, 单位为inches

代码示例:

> pdf("a.pdf", height = 10, width = 10)
> par("din")
[1] 10 10
> par("fin")
[1] 10 10
> par("pin")
[1] 8.76 8.16

首先创建一个绘图设置,这里我们创建一个宽度和高度都为10的pdf , 单位是inches

通过din 参数的返回值可以看到,pdf 对应的宽度和高度都是10 inches

通过 fin 参数的返回值可以看到,figure region 对应的宽度和高度都是10 inches

通过 pin 参数的返回值可以看到,plot region 对应的宽度和高度分别是8.76 和 8.16 inches

device region 的宽度和高度很好理解,是我们在绘图时设置的, 但是figure region 和 plot region 的宽度和高度是如何得到的呢?

在device region 和 figure  region 之间,存在 outer magin, 默认情况下,outer margin 4个方向的值都为0,所以 device region 和 figure region 的宽度和高度一致

我们通过设置 omi 参数的值再来看一下

> pdf("a.pdf", height = 10, width = 10)
> par(omi = c(1, 2, 1, 2))
> par("din")
[1] 10 10
> par("fin")
[1] 6 8

我们可以看到,device region的宽度和高度都是10, 而figure reigon的宽度和高度变成了6和8, 少的就是outer margin的部分

figure region width   = device region width - left outer margin - right outer margin

figure region height  = device region heigth - top outer margin - bottom outer margin

根据上面的公式, figure region 的宽度  10 - 2 - 2 = 6, figure region 的高度 = 10 - 1 - 1 = 8

同样的道理,在figure region 和 plot region 之间存在margin

plot region width   = figure region width - left outer margin - right outer margin

plot region height  = device region heigth - top outer margin - bottom outer margin

代码示例:

> pdf("a.pdf", height = 10, width = 10)
> par(mai = c(1, 2, 1, 2))
> par("fin")
[1] 10 10
> par("pin")
[1] 6 8

根据上面的公式, plot region 的宽度  10 - 2 - 2 = 6, plot region 的高度 = 10 - 1 - 1 = 8

通过上面几个参数的值,对于基本绘图系统中边框的理解就更加清楚了。

R语言绘图边框的更多相关文章

  1. R语言绘图边框的单位

    在R语言中指定画图边框时,通常使用两种单位, lines 和 inches 当然,这两个单位之间是可以相互转换的,那么 1 inch = ? line 答案是1 inches = 5 lines 下面 ...

  2. R语言绘图高质量输出

    R语言通过支持Cairo矢量图形处理的类库,可以创建高质量的矢量图形(PDF,PostScript,SVG) 和 位图(PNG,JPEG, TIFF),同时支持在后台程序中高质量渲染.在ggplot2 ...

  3. linux命令行下使用R语言绘图

    系统:centos 6.4 64bit 环境安装参考:http://hi.baidu.com/solohac/item/4a18e78f1bef9b5825ebd99c 在R语言中可以使用png()等 ...

  4. R语言绘图:时间序列分析 ggplot2绘制ACF PACF

    R语言真是博大精深 方法一 Acf(gold[,2], type = "correlation",lag.max = 100) Acf(gold[,2], type = " ...

  5. 从零开始学习R语言(八)——R语言绘图

    本文首发于知乎专栏:https://zhuanlan.zhihu.com/p/74051739 也同步更新于我的个人博客:https://www.cnblogs.com/nickwu/p/125683 ...

  6. R语言绘图布局

    在R语言中,par 函数可以设置图形边距,其中oma 参数设置outer margin, mar 参数设置margin, 这些边距有什么不同呢,通过box函数可以直观的看到 box 默认在当前图形绘制 ...

  7. R语言绘图002-页面布局

    par().layout().split.screen()函数 1. par()函数的参数详解 函数par()可以用来设置或者获取图形参数,par()本身(括号中不写任何参数)返回当前的图形参数设置( ...

  8. R语言——绘图函数深入学习

    利用R自带数据集 通过data()函数可以查看R自带数据集. > data() 返回以下结果,每一条记录都是一个数据,键入相应的数据名称可以查看具体信息. Data sets in packag ...

  9. R语言绘图时的边界碰撞问题

    当我们在绘图时,经常会遇到这样的问题,添加的文字标记超出了坐标系的问题,导致文字显示不全 比如下面这个例子: plot(c(1,5),c(1,5)) text(5,5.1,"ABCDEF&q ...

随机推荐

  1. python新手中常见疑惑及解答

    1 lambda函数 函数格式是lambda keys:express   匿名函数lambda是一个表达式函数,接受keys参数,返回表达式的值.所以不用return,也没有函数名,经常用在需要ke ...

  2. iptables控制较复杂案例

    场景设定: 管理员:192.168.101.80 公司有三个部门: 工程部:192.168.2.21-192.168.2.20 软件部门:192.168.2.21-192.168.2.30 经理办公室 ...

  3. Javascript玩转继承(一)

    Javascript究竟是一门面向对象的语言,还是一门支持对象的语言,我想每个人都有着自己的看法.那些Javascript忠实的Fans一定讲Javascript是一门面向对象的语言,像<Jav ...

  4. QT中布局器的addStretch函数使用效果

    QBoxLayout中addStretch 函数说明: void QBoxLayout::addStretch(int stretch = 0) Adds a stretchable space (a ...

  5. 【转】32位和64位系统区别及int字节数

    http://blog.csdn.net/zhongzhiwei/article/details/8678885 一)64位系统和32位有什么区别? 1.64bit CPU拥有更大的寻址能力,最大支持 ...

  6. posix多线程--互斥量

    多线程程序在线程间共享数据时,如果多个线程同时访问共享数据就可能有问题.互斥量是解决多个线程间共享数据的方法之一. 1.互斥量初始化两种方式:(1)静态初始化 #include <pthread ...

  7. Alluxio 内存存储系统部署

    一.文件下载和解压 1)下载地址:http://www.alluxio.org/download 2) 解压命令如下: $ wget http://alluxio.org/downloads/file ...

  8. git 分支管理 推送本地分支到远程分支等

    1.创建本地分支 local_branch git branch local_branch 2.创建本地分支local_branch 并切换到local_branch分支 git checkout - ...

  9. C#写的工厂模式

    program.cs file using System; using System.Collections.Generic; using System.Text; namespace Console ...

  10. PDNN: 深度学习的一个Python工具箱

    PDNN: 深度学习的一个Python工具箱 PDNN是一个在Theano环境下开发出来的一个Python深度学习工具箱.它由苗亚杰(Yajie Miao)原创.现在仍然在不断努力去丰富它的功能和扩展 ...