[R] Reading xyz data from a file and plotting a contour plot

Petr Pikal petr.pikal at precheza.cz
Wed Apr 5 13:40:09 CEST 2006


Hi

On 5 Apr 2006 at 10:44, Abhinav Verma wrote:

Date sent:      	Wed, 5 Apr 2006 10:44:41 +0200
From:           	"Abhinav Verma" <abhinav1205 at gmail.com>
To:             	r-help at stat.math.ethz.ch
Subject:        	[R] Reading xyz data from a file and plotting a contour plot

> Hello ,
> 
>  I am very new to R and I tried to find some solutions to my problem
>  in
> the mail archives, but I couldnt.
> 
>  All I need to do is read a data file, which has data in " X Y Z "
>  format
> and then I want to plot a surface plot or a contour plot of this.
> 
> my data is like ..
> 
> 1710 0.626938723432     18.786
> 1582 0.58561524019      9.01
> 1629 0.617393680032     6.075
> 1561 0.57943533994      3.436
> 1557 0.56416723609      9.985
> 1576 0.60443022033      7.71
> 1583 0.573542592476     2.743
> 1627 0.575233663156     2.821
> 1600 0.574245291511     -0.64
> 1658 0.587265947626     2.231

Something like

 tab<-read.table("clipboard")
 tab
     V1        V2     V3
1  1710 0.6269387 18.786
2  1582 0.5856152  9.010
3  1629 0.6173937  6.075
4  1561 0.5794353  3.436
5  1557 0.5641672  9.985
6  1576 0.6044302  7.710
7  1583 0.5735426  2.743
8  1627 0.5752337  2.821
9  1600 0.5742453 -0.640
10 1658 0.5872659  2.231
 > library(akima)
contour(interp(tab$V1, tab$V2, tab$V3))
image(interp(tab$V1, tab$V2, tab$V3))

HTH
Petr




> .....
> .....
> 
> 
>  Any help is appriciated.. Thanks in advance,
> 
> -- Abhi
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html

Petr Pikal
petr.pikal at precheza.cz




More information about the R-help mailing list