[Gstat-info] variogram plot with a priori variance
Edzer Pebesma
edzer.pebesma at uni-muenster.de
Mon Mar 10 08:29:13 CET 2008
I'll modify the source code such that the gstat::: is not needed
anymore, and will document the panel function, and use your example
there. Thanks!
--
Edzer
Paul Hiemstra wrote:
> Hi Giovanni,
>
> I'm happy that it works! Plotting a gstatVariogram object calls the
> function plot.gstatVariogram. In turn that uses the panel function
> vgm.panel.xyplot. This last panel function is normally not available
> to the user, only through the gstat::: syntax. I found this by
> browsing through the gstat-package source code. The variogram plot
> function is documented under ?plot.gstatVariogram, for some other
> things you need to go to the source code in order to find how it works.
>
> cheers,
> Paul
>
> G. Allegri wrote:
>> Thanks Paul, this works perfectly:
>>
>> plot(t0VARIO,VgmANIS_ZON,panel=function (x, y,...){
>> gstat:::vgm.panel.xyplot(x, y,...)
>> panel.abline(h=var(t0$EceZ))
>> })
>>
>> Having previously loaded the lattice library, needed to use
>> panel.abline().
>> I suppose vgm.panel.xyplot is an overloaded method of xyplot, and that
>> calling plot() with a gstat object creates a "vgm.panel.xyplot" panel
>> as default. Is it right?
>> Where is this "low level" code documented?
>>
>> Cheers,
>> Giovanni
>>
>>
>>
>> 2008/3/9, Paul Hiemstra <p.hiemstra at geo.uu.nl>:
>>
>>> Hi Giovanni,
>>>
>>> You only get the line because that is what you specify in the panel
>>> function. To also get the sample variogram and variogram model you
>>> need
>>> to start the panel function with a call to the original panel function
>>> for the variogram (gstat:::vgm.panel.xyplot, don't forget the gstat:::
>>> part) and then add the extra stuff. In general:
>>>
>>> panel = function(x, y, ...){
>>> original_panel_function(x, y, ...)
>>> new_stuff
>>> }
>>>
>>> This is an example of a custom variogram panel function I use:
>>>
>>> function (x, y, model, subscripts, ...)
>>> {
>>> gstat:::vgm.panel.xyplot(x, y, model = model, subscript = TRUE,
>>> ...)
>>> no_digits = function(a) {
>>> if (a > 10)
>>> return(0)
>>> else {
>>> if (a < 1)
>>> return(2)
>>> else return(1)
>>> }
>>> }
>>> nugget = sum(model[1, "psill"])
>>> sill = sum(model[, "psill"])
>>> range = sum(model[, "range"])
>>> txt = paste("Model: ", as.character(model[2, "model"]),
>>> "\nNugget: ",
>>> round(nugget, digits = no_digits(nugget)), "\nSill: ",
>>> round(sill, digits = no_digits(sill)), "\nRange: ",
>>> round(range,
>>> digits = no_digits(range)), sep = "")
>>> ltext(max(x), 0.02 * max(y), txt, font = 2, cex = 0.7, adj = c(1,
>>> 0), col = grey(0.3))
>>> }
>>>
>>> cheers,
>>> Paul
>>>
>>>
>>>
>>>
>>> G. Allegri wrote:
>>> > Sorry for the many posts I'm sending...
>>> > I need to plot the a-priori variance on an anisotropic variogram
>>> plot.
>>> > I've tried using the panel argument, this way:
>>> >
>>> >
>>> plot(t0VARIO,VgmANIS_ZON,panel=function(x,y){panel.abline(h=var(t0$EceZ))})
>>>
>>> >
>>> > where,
>>> > t0VARIO is the ESV
>>> > VgmANIS_ZON is an zonal anisotropic model (two directions)
>>> >
>>> > The problem is that, using the panel function the a-priori variance
>>> > line is plotted on both the direction panels, but not the variograms
>>> > and the model.
>>> > Are there other ways to add graphics to variogram plots?
>>> >
>>> > Thanks again for precious support!
>>> > Giovanni
>>>
>>>
>>>> ------------------------------------------------------------------------
>>>>
>>>>
>>> >
>>> > _______________________________________________
>>> > Gstat-info mailing list
>>> > Gstat-info at geo.uu.nl
>>> > http://mailman.geo.uu.nl/mailman/listinfo/gstat-info
>>> >
>>>
>>>
>>>
>>> --
>>> Drs. Paul Hiemstra
>>> Department of Physical Geography
>>> Faculty of Geosciences
>>> University of Utrecht
>>> Heidelberglaan 2
>>> P.O. Box 80.115
>>> 3508 TC Utrecht
>>> Phone: +31302535773
>>> Fax: +31302531145
>>> http://intamap.geo.uu.nl/~paul
>>>
>>>
>>>
> <
>
More information about the Gstat-info
mailing list