Skip to content

plot.gstatVariogram - overlay multiple models on a single variogram

2 messages · Timothy W. Hilton, Edzer Pebesma

#
Hello,

Using gstat, I would like to overlay several different variogram
models onto a single empirical semivariogram.  I am having trouble
mastering the necessary lattice plotting commands.  Using an example
from this list (or maybe the docs for gstat; I'm not sure):

mypanel = function(x,y,...) {                                                 
  vgm.panel.xyplot(x,y,...)
}

require(gstat)
g = gstat(formula = log(zinc)~1, data = meuse)
v = variogram(log(zinc)~1,meuse)
vgm1 = fit.variogram(v,vgm(1, "Sph", 900,1))
vgm2 = fit.variogram(v,vgm(1, "Exp", 300,1))
print(plot(v, model=vgm1 ,panel=mypanel))


This plots the variogram with vgm1.  I would now like to overlay vgm2,
in a different color.  I have tried many variations on making model a
list, or trying to write a panel function that will plot the
variogram, then both models sequentially, but I can't get anything to
work.

Many thanks for any help,
Tim
#
Try:

mypanel = function(x,y,...) {                                                 
  vgm.panel.xyplot(x,y,...)
  panel.lines(variogramLine(vgm2,1500))
}

require(gstat)
g = gstat(formula = log(zinc)~1, data = meuse)
v = variogram(log(zinc)~1,meuse)
vgm1 = fit.variogram(v,vgm(1, "Sph", 900,1))
vgm2 = fit.variogram(v,vgm(1, "Exp", 300,1))
print(plot(v, model=vgm1 ,panel=mypanel))

--
Edzer
Timothy W. Hilton wrote: