[R] imaging and contouring

Gregory Snow Greg.Snow at intermountainmail.org
Thu Apr 6 17:13:16 CEST 2006


The help for filled.contour suggests using the plot.axes argument to annotate a plot, try changing the last part of your 3rd example to:

filled.contour(nlong,nlat,z1,col=rainbow 
(100),xlab="longitude",ylab="latitude",
plot.axes=map(add=TRUE))

Or 

filled.contour(nlong,nlat,z1,col=rainbow 
(100),xlab="longitude",ylab="latitude",
plot.axes={box();axis(1);axis(2);map(add=TRUE)})

Hope this helps

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at intermountainmail.org
(801) 408-8111
 
 

> -----Original Message-----
> From: r-help-bounces at stat.math.ethz.ch 
> [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of 
> Nicolas Degallier
> Sent: Tuesday, April 04, 2006 8:20 AM
> To: Ethz. Ch
> Cc: Roger Bivand
> Subject: [R] imaging and contouring
> 
> Dear R'Helpers and Colleagues,
> 
> I have looked in the documentation, asked to some colleagues 
> in the lab, but was unable to solve the following difficulty.
> 
> I am running R on a  iMac  G5 with OS 10.4.
> 
> The file below (73 rows x 144 col) shows the values of a 
> climatic index on the globe with a grid of 2,5 °  x 2,5 ° (NA 
> = no value):
> 
>  
> With image() and map() and running the following function:
> 
> dessin_i<-function(nomfichier="ERA40NA.dat",lat=73,long=144) 
> { #définition de la fonction
> library(maps)
> a <- read.table(nomfichier) #lecture du fichier
> z <- array(0,dim=c(long,lat)) #création d'un tableau de 0
> z <- t(a) #transposition de la matrice a en z
> z1<-rbind(z[65:long,],z[1:64,]) #centrage de la carte sur greenwich
> nlat<-seq(-90,90,2.5) #définition des latitudes / ordonnées de 2,5°  
> en 2,5°
> nlong <- seq(-180,177.5,2.5) #définition des longitudes /abcisses de  
> 2,5° en 2,5°
> image(nlong,nlat,z1,col=rainbow 
> (100),xlab="longitude",ylab="latitude") #traçage
> map(add=TRUE) #superposition de la carte des continents et pays
> }
> 
> And then:
>  >dessin_i()
> 
> I got the following figure (anonymous ftp):
> 
> ftp://ftp.lodyc.jussieu.fr/ndelod/ND_Fig1.pdf
> 
> running the following:
> 
> dessin_c<-function(nomfichier="ERA40NA.dat",lat=73,long=144) 
> { #définition de la fonction
> library(maps) #chargement du package maps
> a <- read.table(nomfichier) #lecture des données
> z <- array(0,dim=c(long,lat)) #création d'un tableau de 0
> z <- t(a) #transposition de la matrice a en z
> z1<-rbind(z[65:long,],z[1:64,]) #centrage de la carte sur greenwich
> nlat<-seq(-90,90,2.5) #définition des latitudes / ordonnées de 2,5°  
> en 2,5°
> nlong <- seq(-180,177.5,2.5) #définition des longitudes /abcisses de  
> 2,5° en 2,5°
> contour(nlong,nlat,z1,col=rainbow 
> (100),xlab="longitude",ylab="latitude") #traçage
> map(add=TRUE) #superposition de la carte des continents et pays
> }
> 
> and:
>  >dessin_c()
> 
> I got the following figure (anonymous ftp):
> 
> ftp://ftp.lodyc.jussieu.fr/ndelod/ND_Fig2.pdf
> 
> Finally, running:
> 
> dessin_f<-function(nomfichier="ERA40NA.dat",lat=73,long=144) 
> { #définition de la fonction
> library(maps) #chargement du package maps
> a <- read.table(nomfichier) #lecture des données
> z <- array(0,dim=c(long,lat)) #création d'un tableau de 0
> z <- t(a) #transposition de la matrice a en z
> z1<-rbind(z[65:long,],z[1:64,]) #centrage de la carte sur greenwich
> nlat<-seq(-90,90,2.5) #définition des latitudes / ordonnées de 2,5°  
> en 2,5°
> nlong <- seq(-180,177.5,2.5) #définition des longitudes /abcisses de  
> 2,5° en 2,5°
> filled.contour(nlong,nlat,z1,col=rainbow 
> (100),xlab="longitude",ylab="latitude") #traçage
> map(add=TRUE) #superposition de la carte des continents et pays
> }
> 
> and:
>  >dessin_f()
> 
> I got the following figure (anonymous ftp):
> 
> ftp://ftp.lodyc.jussieu.fr/ndelod/ND_Fig3.pdf
> 
> It may be similar to what I am looking for, i.e. the first figure  
> with smoothed contours and a scale of the colors/values but I have  
> been unable (or didn't found the right options) to put the 
> map in the  
> right place.
> 
> Is it possible and how to do it:
> 1)  to use "filled.contour()" without the scale?
> 2) to put again the map and the coloured contours adjusted?
> 3) to obtain the colours of the first figure with "filled.contour"  
> function?
> 
> A subsidiary question is yet: how to obtain levels lines thicker and/ 
> or in other colour only for specified values of z1?
> 
> Many thanks in advance.
> 
> Sincerely,
> 
> Nicolas Degallier
> 
> UMR 7159 / IRD UR182
> Laboratoire d'Océanographie et du Climat, Expérimentation et  
> Approches Numériques (LOCEAN)
> Tour 45-55, 4e ét., case 100, 4 place Jussieu
> 75252  Paris Cedex 5  France
> tél: (33) 01 44 27 51 57
> fax: (33) 01 44 27 38 05
> 
> E-mail: <Nicolas.Degallier at ird.fr>
> pdf reprints (anonymous ftp): ftp://ftp.lodyc.jussieu.fr/ndelod
> 
> 
> ______________________________________________
> 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
>




More information about the R-help mailing list