日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 综合教程 >内容正文

综合教程

R语言绘图边框

發布時間:2023/12/13 综合教程 24 生活家
生活随笔 收集整理的這篇文章主要介紹了 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

通過上面幾個參數的值,對于基本繪圖系統中邊框的理解就更加清楚了。

總結

以上是生活随笔為你收集整理的R语言绘图边框的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。