[R-sig-Geo] Background behind text in a map

Laurence Amilhat Laurence.Amilhat at toulouse.inra.fr
Tue May 15 15:04:31 CEST 2007


Hello everyone,


I have this code to create a map of europe, and plot some cities on it 
with their names:

library(maps)
library(mapdata)
library(spmaps)
library(grid)

mesvilles 
<-"/home/lamilhat/AQUAGENOME/DRAW_MAP/extra_maps/villes_coords_R.txt" 
#file with 3 columns
 a <-read.table(mesvilles)
 x<-a[,1] #first column longitude
 y<-a[,2] #second column lattitude
 z<-a[,3] #third column city name

# I plot the map on a png file
png(file="/home/lamilhat/AQUAGENOME/DRAW_MAP/extra_maps/R_output.png", 
width= 1200, height= 700)
map(database="world", xlim=c(-25,70),ylim=c(35,71), fill=TRUE, col="grey")
points(x,y, col="red", pch=16)
text(x,y,z, pos=3)
dev.off()

This code give me the map attached to this message.
This works fine, but the names of the cities are not readable in some case.
I would like to add a background color (white) behind the text to be 
more readable.

Do you known a function that can be used for that?


Thank you for your help,


Laurence Amilhat



-------------- next part --------------
A non-text attachment was scrubbed...
Name: map_test.png
Type: image/png
Size: 83157 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20070515/4d963cbc/attachment.png>


More information about the R-sig-Geo mailing list