R繪圖系統邊框詳解


在R語言的基礎繪圖系統中,有plot, figure, outer, inner 共4種邊框;

這四種邊框實際上明確了整個繪圖設備的布局

1) outer,  當我們聲明一個繪圖設備的時候,outer 指的就是這個設備上,下,左,右4個邊框

代碼示例:

plot(1:5)
box(which = "outer", col = "red", lwd = 10)

生成的圖片如下:

可以看到 outer 邊框為整個繪圖設備最外圈的邊框

2) inner : outer 是整個繪圖設備最外圈,inner 邊框中就是實際用於繪圖的區域,默認情況下整個繪圖設備都用於繪制圖表,所以inner 邊框和 outer 邊框是重合的,通過設置 outer margin 可以將 inner  和 outer  邊框區分開

代碼示例:

par(omi = c(1, 1, 1, 1))
plot(1:5)
box(which = "outer", col = "red",  lwd = 10)
box(which = "inner", col = "blue", lwd = 5)

生成的圖片如下:

通過設置outer magin , 可以看到 inner  邊框為藍色, 紅色的是 outer  邊框

3)figure : inner 邊框中為實際的繪圖區域, 對於繪圖區域,有時有可以分成多個子區域,每個區域用來繪制一幅圖,figure 指的就是每一副圖的邊框

代碼示例:

par(omi = c(1, 1, 1, 1), mfrow = c(1, 2))
plot(1:5)
box(which = "figure", col = "red", lwd = 2)
plot(1:5)
box(which = "figure", col = "blue", lwd = 2)

生成的圖片如下:

這里將繪圖區域分成了兩個子區域,從圖中可以看出,figure 是每個子圖的邊框

4) plot : 每幅圖的坐標系所處的邊框

代碼示例:

par(omi = c(1, 1, 1, 1), mfrow = c(1, 2))
plot(1:5)
box(which = "plot",   col = "red", lwd = 2)
box(which = "figure", col = "red", lwd = 2)
plot(1:5)
box(which = "plot",   col = "blue", lwd = 2)
box(which = "figure", col = "blue", lwd = 2)

生成的圖片如下:

從圖中可以看出,plot 邊框就是每個子圖的坐標系所處的邊框, 在 plot 邊框和 figure 邊框之間處所的空白區域就是 margin

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM