Dear Edzer,
I tried your solution but I still have one problem. See the code below:
rad_data_mod$sph = fit.variogram(rad_data_vgm,vgm(psill=60,model="Sph",
range=40e3,nugget=5))
rad_data_mod$exp = fit.variogram(rad_data_vgm,vgm(psill=60,model="Exp",
range=40e3,nugget=5))
rad_data_mod$gau = fit.variogram(rad_data_vgm,vgm(psill=60,model="Gau",
range=40e3,nugget=5))
rad_data_mod$mat = fit.variogram(rad_data_vgm,vgm(psill=60,model="Mat",
range=40e3,nugget=5,kappa=1))
g = gstat(formula = val~1,data = rad_data)
g = gstat(g,formula = val~1,data = rad_data)
g = gstat(g,formula = val~1,data = rad_data)
g = gstat(g,formula = val~1,data = rad_data)
plot(variogram(g,cross = F),
layout = c(2,2),
model = list(var1 = rad_data_mod$sph,
var2 = rad_data_mod$exp,
var3 = rad_data_mod$gau,
var5 = rad_data_mod$mat),
)
Var1 is printed in the lower left corner, var2 in the lower right corner
and var3 in the upper left corner. Var4 should appear in the upper right
corner. But the upper right corner is skipped and a new graph is made with
just var4 at the lower left corner. If I change layout to c(5,1) the first
three variograms appear at the first three positions from the left. But
var4 is printed at the 5th position, skipping the 4th position.
In both examples for layout var4 appears at the 5th position. How can this
be solved?
I use gstat 0.9-33 and R 2.4.0. (Both the lastest versions I think)
Paul
At 23:34 24-10-2006, Edzer J. Pebesma wrote:
>Paul, please note that at least 5 R packages calculate variograms, and not
>everyone can see from your email address which one you are using (gstat).
>
>plot is a generic method; to find which instance is called try
>
>class(plot(rad_data_vgm,rad_data_mod$sph))
>[1] "trellis"
>
>so the plot returns is actually a trellis object; the default action on
>returned objects is to print it, using the print.trellis function. Read
>its help,
>
>library(lattice)
>?print.trellis
>
>to find out how to arrange multiple trellis objects on a single page.
>Trellis objects don't obey layout().
>
>More likely you don't want separate plots but rather a single trellis
>object; you may want to work along these lines:
>
>library(gstat)
>g = gstat(formula = log(zinc)~1, data = meuse)
>g = gstat(g, formula = log(zinc)~1, data = meuse) # define it twice
>v = variogram(log(zinc)~1,meuse)
>vgm1 = fit.variogram(v,vgm(1, "Sph", 900,1))
>vgm2 = fit.variogram(v,vgm(1, "Exp", 300,1))
>plot(variogram(g,cross=F),layout=c(1,2),model=list(var1=vgm1,var2=vgm2))
>--
>Edzer
>
>
>Paul Hiemstra wrote:
>>Dear All,
>>
>>I want to make a plot that compares several different models fitted to
>>the same experimental variogram.
>>
>># Try different models
>>rad_data_mod$sph = fit.variogram(rad_data_vgm,vgm(psill=60,model="Sph",
>>range=40e3,nugget=5))
>>rad_data_mod$exp = fit.variogram(rad_data_vgm,vgm(psill=60,model="Exp",
>>range=40e3,nugget=5))
>>rad_data_mod$gau = fit.variogram(rad_data_vgm,vgm(psill=60,model="Gau",
>>range=40e3,nugget=5))
>>
>>Then I use layout to divide the plotting area into 4 different areas:
>>
>>layout(matrix(c(1,2,3,4),2,2,byrow=TRUE), TRUE)
>>
>>Now I want to fill the plot area by calling the plot() command three times.
>>
>>plot(rad_data_vgm,rad_data_mod$sph)
>>plot(rad_data_vgm,rad_data_mod$exp)
>>plot(rad_data_vgm,rad_data_mod$gau)
>>
>>I expected that the sub-areas would be filled with the three plots. But
>>the variogram plot fills the entire plot area and not just the small
>>sub-area. A test function:
>>
>>x = seq(1:1000)
>>y = x^2
>>plot(x,y)
>>plot(x,y)
>>plot(x,y)
>>
>>performed as expected producing one plot with four subplots.
>>
>>Does anybody know how to make such a trellis plot for variogram plots?
>>
>>kind regards,
>>
>>Paul Hiemstra [[alternative HTML version deleted]]
>>
>>_______________________________________________
>>R-sig-Geo mailing list
>>[email protected]
>>https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>
>
[[alternative HTML version deleted]]
_______________________________________________
R-sig-Geo mailing list
[email protected]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo