[R-sig-Geo] spplot with legend only, and legend inside the plotting area

Mauricio Zambrano-Bigiarini mauricio.zambrano at jrc.ec.europa.eu
Thu Mar 8 18:33:25 CET 2012


On 08/03/12 18:22, Oscar Perpiñán Lamigueiro wrote:
> Mauricio Zambrano-Bigiarini<mauricio.zambrano at jrc.ec.europa.eu>  writes:
>
>> Thanks Oscar !. I didn't realise about 'latticeExtra' instead of lattice...
>>
>> One last question. By using c(), is it possible to put different axis
>> labels for each plot ?
>> -------------- START ----------------
>> library(sp)
>> xyz = data.frame(expand.grid(x=1:10,y=1:10),rnorm(100))
>> coordinates(xyz)=~x+y
>>
>> # Different spatial extent for the 2nd dummy set
>> xyz2 = data.frame(expand.grid(x=100:200,y=100:200),rnorm(10201))
>> coordinates(xyz2)=~x+y
>>
>> # only to get the default values from 'auto.key'
>> dummy<- spplot(xyz, cex=2, alpha=0.7, xlab="X1", ylab="Y1",
>> scales=list(draw=TRUE))
>> dummy2<- spplot(xyz2, cex=2, alpha=0.7, xlab="X2", ylab="Y2")
>>
>> # checking that 'dummy' is a trellis
>> class(dummy)
>>
>> library(lattice)
>> library(latticeExtra)
>> cObj<- c(dummy, dummy2, dummy, dummy2, layout=c(2,4), merge.legends=FALSE)
>> update(cObj)
>>
>> -------------- END ----------------
>
> Yes, it is possible. You have to modify the parameters with update:
>
> cObj<- c(dummy, dummy2, dummy, dummy2)
> update(cObj, xlab=c('X1', 'X2'), ylab.right='Y2')
>
> Best,

Thanks Oscar !.

Now I know two solutions for the initial problem :)

All the best,

Mauricio

-- 
=======================================================
FLOODS Action
Water Resources Unit (H01)
Institute for Environment and Sustainability (IES)
European Commission, Joint Research Centre (JRC)
webinfo    : http://floods.jrc.ec.europa.eu/
=======================================================
DISCLAIMER:
"The views expressed are purely those of the writer
and may not in any circumstances be regarded as stating
an official position of the European Commission."
=======================================================
Linux user #454569 -- Ubuntu user #17469
=======================================================
"If Columbus had turned back, no one would have blamed him.
Of course, no one would have remembered him either."
(Source Unknown)



More information about the R-sig-Geo mailing list