在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. Common Probability Distributions

    Common Probability Distributions Probability Distribution A probability distribution describes the p ...

  2. Vector3.Set的正确使用

    直接调用position.Set会发现没有用.其实和其本身是结构体有关,要当成一个值类型来看待,因为他全部是在栈中. transform.position.Set(,,); 改成这样即可: var t ...

  3. cocos2d-x笔记-CCGLProgram

    引擎提供了CCGLProgram类来处理着色器相关操作,对当前绘图程序进行了封装,其中使用频率最高的应该是获取着色器程序的接口: const GLuint getProgram(); 该接口返回了当前 ...

  4. linux perf and tracer ,java Flame Graph

    http://www.brendangregg.com/flamegraphs.html http://hg.openjdk.java.net/jdk8u/jdk8u/hotspot/rev/e826 ...

  5. ny220 推桌子

    推桌子 时间限制:1000 ms  |  内存限制:65535 KB 难度:3 描述 The famous ACM (Advanced Computer Maker) Company has rent ...

  6. Mac OSX系统、Linux、Windows命令行教程

    目录 Mac OSX系统.Linux.Windows命令行教程 一.各系统终端的使用方法 二.各系统命令的功能 Mac OSX系统.Linux.Windows命令行教程 用你的终端做一些事情 (com ...

  7. vue实现复制粘贴的两种形式

    方式一: 1.安装clipboard:npm install clipboard 2.src/utils/clipboard.js import Vue from 'vue' import Clipb ...

  8. linux三剑客grep|sed|awk实践

    最好先学习正则表达式的基本用法,以及正则表达式BREs,EREs,PREs的区别 此坑待填 grep sed awk

  9. u-boot中添加自定义命令

    1.u-boot命令机制u-boot中,每个命令都使用一个struct cmd_tbl_s结构体定义,该定义在include/command.h中实现:struct cmd_tbl_s{ char * ...

  10. 【Maven学习】Maven打包生成普通jar包、可运行jar包、包含所有依赖的jar包

    http://blog.csdn.net/u013177446/article/details/54134394 ******************************************* ...