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
通過上面幾個參數的值,對于基本繪圖系統中邊框的理解就更加清楚了。
總結
- 上一篇: std::reserves使用
- 下一篇: Intel CPU Microarchi