中進行專門的繪圖功能的瓷磚繪圖我想將以下繪圖中的4個繪製爲par(mfrow=c(2,2))
類型的排列。如何從程序包
install.packages("wavelets")
require(wavelets)
dat <- rnorm(100)
plot.modwt(modwt(dat)) #4 of these in a 2x2 grid is desired
然而,layout
和mfrow
的企圖,都沒有成功。
我會給予正確的答案一個賞金。
中進行專門的繪圖功能的瓷磚繪圖我想將以下繪圖中的4個繪製爲par(mfrow=c(2,2))
類型的排列。如何從程序包
install.packages("wavelets")
require(wavelets)
dat <- rnorm(100)
plot.modwt(modwt(dat)) #4 of these in a 2x2 grid is desired
然而,layout
和mfrow
的企圖,都沒有成功。
我會給予正確的答案一個賞金。
由於@plannapus評論,功能plot.modwt
已經調用佈局。所以你需要改變原來的功能。
plot.modwt
,您將獲得完整的定義。my.plot.modwt
。設置您的新佈局。這爲我工作:
nf = layout(matrix(c(3, 1, 4, 2, 7, 5,8, 6), 4, 2, byrow = TRUE),
c(2,2), c(2,1, 2, 1), TRUE)
layout.show(nf)
調用你的函數(4次)創建地塊:
my.plot.modwt(modwt(dat1))
my.plot.modwt(modwt(dat2))
my.plot.modwt(modwt(dat3))
my.plot.modwt(modwt(dat4))
注意,可能需要一些其他的改動佈局。
我的代碼:
y.plot.modwt = function (x, levels = NULL, draw.boundary = FALSE, type = "stack",
col.plot = "black", col.boundary = "red", X.xtick.at = NULL,
X.ytick.at = NULL, Stack.xtick.at = NULL, Stack.ytick.at = NULL,
X.xlab = "t", y.rlabs = TRUE, plot.X = TRUE, plot.W = TRUE,
plot.V = TRUE, ...)
{
stackplot.modwt <- function(x, w.range, v.range, col.plot,
col.boundary, draw.boundary, X.xtick.at, X.ytick.at,
Stack.xtick.at, Stack.ytick.at, X.xlab = "t", plot.X = TRUE) {
innerplot <- function(x, y, type = "l", xtick.at, ytick.at) {
if (is.null(xtick.at) == FALSE || is.null(ytick.at) ==
FALSE) {
plot(x, y, type = "l", axes = FALSE, frame.plot = TRUE)
<snip>
if (plot.X) {
#nf <- layout(matrix(c(2, 2, 1, 1), 2, 2, byrow = TRUE),
# c(1, 2), c(2, 1), TRUE)
par(mai = c(0.6, 0.4, 0.1, 0.6))
<snip>
}
它不起作用。只有一個情節在右側,並且每次連續調用'my.plot.modwt'時都會覆蓋。 – user2763361
@ user2763361它適用於我。我已經放下了代碼的精簡版。 – csgillespie
我不確定你爲什麼評論'佈局?'這不是我們應該改變的嗎?我是在說我用你建議的路線替換了你所評論的內容,但它不起作用。 – user2763361
與具體情節的問題是,它已經調用'layout'嵌入,因此任何企圖都將被覆蓋。見函數源代碼片段:'... if(plot.X)nf < - layout(matrix(c(2,2,1,1),2,2,byrow = TRUE), (1,2),c(2,1),TRUE)...' – plannapus