• R语言绘图边框


    在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

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

  • 相关阅读:
    如何清除去掉PPT文字下的波浪线
    使用SQLyog备份还原数据库
    excel冻结首行
    查看Mysql版本号
    java23种设计模式
    Elasticsearch Java High Level REST Client(Bulk API)
    Elasticsearch Java High Level REST Client工具类
    springboot2.0整合es报错 nested exception is java.lang.IllegalStateException: availableProcessors is already set to [4], rejecting [4]
    ElasticSearch 应用开发Transport Client和Rest Client网络协议
    单例和多例的区别
  • 原文地址:https://www.cnblogs.com/xudongliang/p/6888884.html
Copyright © 2020-2023  润新知