[R-sig-Geo] Variogram does not plot correctly when using layout()

Edzer J. Pebesma e.pebesma at geo.uu.nl
Tue Oct 24 23:34:03 CEST 2006


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
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>




More information about the R-sig-Geo mailing list