[R-sig-Geo] Add text INSIDE spplot map

Edzer Pebesma edzer.pebesma at uni-muenster.de
Mon Jul 11 15:13:46 CEST 2011


Yes, you can, but it might not be trivial.

In particular, you will have to dive into how this is done with the
routines in package grid. The book "R graphics" and the accompanying web
site, http://www.stat.auckland.ac.nz/~paul/RGraphics/rgraphics.html
contain many examples.

See e.g. sp::mapLegendGrob for a function in sp that uses some functions
in package grid directly.

Hth,

On 07/11/2011 02:32 PM, Jose Iparraguirre wrote:
> Thanks Tom,
> 
> Here's an example using the usual dataset, meuse.
> 
>> data(meuse)
>> coordinates(meuse) = ~x+y
>> l1 = list("sp.text", c(179050, 330877),"Hola",col="red",font=2)
>> spplot(meuse, c("ffreq"), sp.layout=list(l1), col.regions= "black", 
> + pch=c(19), key.space=list(x=0.1,y=.95,corner=c(0,1)))
> 
> Here, "Hola" is printed 'within the cloud', and it's not very legible -imagine thousands of additional points. I forgot to mention that I'd experimented with first=F/T, and the only change is that with first=TRUE, of course, the text 'Hola' is not printed. 
> So, let me change the request of advice slightly: can I put such a text in such coordinates within a box, filling the box with a different colour, so that the text becomes more visible? (neither 'fill' nor 'bty' seem to work as elements of the list...).
> 
> Thanks in advance, and regards to everyone!
> 
> José
> 
> 
> 
> José Iparraguirre
> Chief Economist
> Age UK
> 
> T 020 303 31482
> E Jose.Iparraguirre at ageuk.org.uk
> 
> Tavis House, 1- 6 Tavistock Square
> London, WC1H 9NB
> www.ageuk.org.uk | ageukblog.org.uk | @AgeUKPA
> 
> 
> 
> 
> -----Original Message-----
> From: Tom Gottfried [mailto:tom.gottfried at tum.de] 
> Sent: 11 July 2011 08:00
> To: Jose Iparraguirre
> Subject: Re: [R-sig-Geo] Add text INSIDE spplot map
> 
> Hi,
> 
> first guess: did you try to add 'first=FALSE' to sp.layout (see ?spplot)?
> 
> Am 08.07.2011 17:09, schrieb Jose Iparraguirre:
>> Hi,
>>
>> Sorry if I'm not accompanying a piece of code, but the following question is general enough.
>> I want to add some text markers/labels (say, the names of a couple of cities) within the figure plotted using spplot (in the sp library). I'm plotting spatial points.
>> Using sp.layout I can add a text outside the points, but when I change the coordinates to place the text within the cloud of points, it seems to go 'behind' the points. Is there a way of bringing the text forward or 'superimpose' it on top of the points mapped with spplot?
> 
> For me it's not clear what means "outside the points" and "within the cloud of points". Maybe a 
> reproducible example would clarify, though.
> 
> Tom
> 
>> Thanks,
>>
>> José
>>
>> José Iparraguirre
>> Chief Economist
>> Age UK
>>
>> T 020 303 31482
>> E Jose.Iparraguirre at ageuk.org.uk<mailto:Jose.Iparraguirre at ageuk.org.uk>
>>
>> Tavis House, 1- 6 Tavistock Square
>> London, WC1H 9NB
>> www.ageuk.org.uk<http://www.ageuk.org.uk>  | ageukblog.org.uk<http://ageukblog.org.uk/>  | @AgeUKPA<http://twitter.com/ageukpa>
>>
>>
>>
>>
>>
>>
>>
>>
>> Age UK  Improving later life
>>
>>
>>
>> www.ageuk.org.uk
>>
>>
>>
>>
>>
>> -------------------------------
>>
>>
>>
>> Age UK is a registered charity and company limited by guarantee, (registered charity number 1128267, registered company number 6825798)
>>
>>
>>
>> Registered office:207-221 Pentonville Road, London N1 9UZ
>>
>>
>>
>> ------------------------------
>>
>>
>>
>> This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you receive a message in error, please advise the sender and delete immediately.
>>
>>
>>
>> Except where this email is sent in the usual course of our business, any opinions expressed in this email are those of the author and do not necessarily reflect the opinions of Age UK or its subsidiaries and associated companies. Age UK monitors all e-mail transmissions passing through its network and may block or modify mails which are deemed to be unsuitable.
>>
>>
>>
>> Age Concern England (charity number 261794) and Help the Aged (charity number 272786) and their trading and other associated companies merged on 1st April 2009 to form Age UK, a single charity dedicated to improving the lives of  people in later life . The three national Age Concerns in Scotland, Northern Ireland and Wales have also merged with Help the Aged in these nations to form three registered charities: Age Scotland, Age NI, Age Cymru.
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> 	[[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
Weseler Straße 253, 48151 Münster, Germany. Phone: +49 251
8333081, Fax: +49 251 8339763  http://ifgi.uni-muenster.de
http://www.52north.org/geostatistics      e.pebesma at wwu.de



More information about the R-sig-Geo mailing list