[R-sig-Geo] How to draw two variogram curves in one plot

Edzer Pebesma edzer.pebesma at uni-muenster.de
Thu Sep 4 08:06:51 CEST 2014

On 09/04/2014 04:57 AM, lwwhdz wrote:
> Dear all
>      I am doing some work on regression kriging in R. Now I want to plot the varigrom curves of the dependent variable (A) and the regression residuals (B) before kriging. With this plot, I can easily to compare the autocorrelation (e.g. sill, range & nugget) of A and B.  I tried the following two commond, but it failed. 
> ......
> plot(variogram(A~1,data), vgm_a,  pch = 19, col = "black", lwd=2, add=TRUE) 
> plot(variogram(B~1,data), vgm_b,  pch = 19, col = "black", lwd=2) 
> ......
>     Is there anyone have any ideas? Thanks very much!

Yes, compose incrementally using base plot:

a = variogram(A~1,data)
b = variogram(B~1,data)
plot(gamma ~ dist, a, pch = 19)
points(gamma ~ dist, b, pch = 20) # use another pch!
lines(variogramLine(vgm_a, max(a$gamma)))
lines(variogramLine(vgm_b, max(a$gamma), col = 2))

in the plot() command you probably want to specify xlim and ylim in
order to have (0,0) as the plot origin.

> Wang Li
> Phd Candidate in University of Chinese Academy of Sciences (UCAS) and Institute of Remote Sensing and Digital Earth, CAS,The State Key Laboratory of Remote Sensing Science
> CAS Olympic S&T Park, No. 20 at Datun Road, Chaoyang, Beijing, P.R.C. (P. O. Box 9718)
> lwwhdz at sina.com
> lwwhdz at gmail.com
> (+86)18810433086
> 	[[alternative HTML version deleted]]
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Edzer Pebesma
Institute for Geoinformatics (ifgi), University of Münster
Heisenbergstraße 2, 48149 Münster, Germany. Phone: +49 251
83 33081 http://ifgi.uni-muenster.de GPG key ID 0xAC227795

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 490 bytes
Desc: OpenPGP digital signature
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20140904/717e65ee/attachment.bin>

More information about the R-sig-Geo mailing list