在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. dia无法输入中文?

    解决方法: 以管理员权限打开/usr/bin/dia ,做如下修改 #dia-gnome --integrated "$@" dia-gnome "$@"

  2. asp.net 通用的连接数据库实例代码

    asp.net中数据库连接代码,有需要的朋友可以参考一下. <%@ Page Language="C#" AutoEventWireup="true" C ...

  3. [Linux] 一次SSH认证失败引发的关于通过日志查错误的思考

    一.缘由: 早上在用SSH公钥认证打通所有的机器,有一台机器在完成一些列操作后密钥登陆失败,其他机器一切正常. 错误如下:Public-key authentication with the serv ...

  4. %02x和%2x区别

    %02x  (x代表以十六进制形式输出,02代表不足两位,前面补0输出,如果超过两位,则以实际输出) 例: #include <stdio.h> #include <stdint.h ...

  5. WCF transport-and-message-security

    Things to Consider When Implementing a Load Balancer with WCF https://msdn.microsoft.com/library/hh2 ...

  6. 【Ubuntu】用户切换到root

    出于安全考虑,默认时 Ubuntu 的 root 用户时没有固定密码的,它的密码是随机产生并且动态改变的,貌似是每5分钟改变一次,所以用 su(switch user) 是不可以的,因为我们不知道 r ...

  7. postgresql MVCC详解

    postgresql MVCC详解 1.postgresql隐藏列 1)tableoid 表对象唯一标识符 2)xmin 插入操作的事务标识符 3)xmax 删除操作的事务标识符 4)cmin 插入操 ...

  8. 关于ajax上传文件的流程 和选择图片立即显示

    关键点: 1.制作一个表单..然后把上传字段附加到该表单中 2.制作一个框架..把表单的_target的属性指向该框架. 3.提交表单.. jQuery.extend({ createUploadIf ...

  9. c# 封装的7zip压缩 (全源码,不含任何类库)

    1,从soureforge下载sdk(包括汇编,c,c++,c#,java) 下载地址http://nchc.dl.sourceforge.net/project/sevenzip/LZMA%20SD ...

  10. code标签和pre标签的定义

    前些日子一同事问了我一个关于code标签和pre标签的问题,嗯,是的,这两个标签凑到一块,便出现了问题.于是总结了一下.此文就重点谈一下code标签和pre标签喽,谈谈他们的定义,区别,应用以及这两个 ...