[R] Overlaying a single contour from a new data array in levelplot

Jenny Barnes jmb at mssl.ucl.ac.uk
Tue Jul 31 12:03:25 CEST 2007


Dear Deepayan,

Thank you once again. I needed to install the latest versions of R and lattice 
and now it all works fine and the border is in white, which is perfect. Thank 
you for all the support you offer users of lattice,

Best Wishes,

Jenny

>That should have been fixed by now. Is there anything that's not
>working as you expect? My code had:
>
>   lapply(add.cl, panel.polygon, border = 'red')
>
>which should have made the borders red. If it doesn't, you probably
>need to upgrade to a recent version of R/lattice. If it does, changing
>it to border='white' should suffice. If that doesn't work, please
>provide a reproducible example.
>
>-Deepayan
>

>
>On 7/30/07, Jenny Barnes <jmb at mssl.ucl.ac.uk> wrote:
>> Dear Deepayan
>>
>> Thank you for your response - it has proved very very helpful, I can't thank 
you
>> enough!
>>
>> I have another question for you if you have time to reply. I know you have 
been
>> asked about the colour of the polygon outline before (27 April 2007) and you
>> replied that is a bug and the border can only be black or transparent...
>>
>> I was wondering if you have found a way to change the colour of the outline
>> since this correspondence? If not please can you tell me how to get around 
this
>> myself? You mentioned writing a replacement to lpolygon - I do not know how 
to
>> do this - would it be possible for you to guide me further?
>
>> I would really benefit from having the border of the polygon in white as it 
goes
>> over the "sea" which is also white and would therefore only be seen over the
>> "land", much neater!
>>
>> Many thanks,
>>
>> Jenny
>>
>>
>>
>> On 7/24/07, Jenny Barnes <jmb_at_mssl.ucl.ac.uk> wrote:
>> > Dear R-Help community,
>> >
>> > I am trying to overlay a single contour line over a correlation plot using
>> > levelplot in the lattice package. These are the two arrays:
>> >
>> > 1) a correlation plot over Africa - so each grid square is a different 
colour
>> > dependent on correlation - this is in an array: result_cor with 
dim[465,465]
>> >
>> > 2) a single contour line from a ***different data source*** - this is from
>> data
>> > related to the p-values for the above correlation plot - I want to overlay
>> only
>> > the 95% confidence contour. The p-values are stored in an array:
>> result.p.values
>> > with same dimensions as above.
>> >
>> > I have read about using panel.levelplot and panel.contourplot in the R-help
>> > mailing list but I don't know the right way to call two different data 
arrays,
>> > can anybody help me please? I appreciate your time and help with this
>> question.
>>
>> I can think of a couple of different ways, but the simplest will probably be 
to
>> compute the single contour beforehand and add it after the standard levelplot
>> using a panel function. E.g., using the 'volcano' data for both matrices:
>>
>> ## you need the explicit x and y arguments because ## the default is 
different
>> from levelplot.
>>
>> vcl <- contourLines(x = seq_len(nrow(volcano)),
>>
>>                    y = seq_len(ncol(volcano)),
>>                    z = volcano,
>>                    levels = c(172, 182))
>>
>> levelplot(volcano, add.cl = vcl,
>>           panel = function(..., add.cl) {
>>               panel.levelplot(...)
>>               lapply(add.cl, panel.polygon, border = 'red')
>>           })
>>
>>
>> -Deepayan ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> Jennifer Barnes
>> PhD student: long range drought prediction
>> Climate Extremes Group
>> Department of Space and Climate Physics
>> University College London
>> Holmbury St Mary
>> Dorking, Surrey, RH5 6NT
>> Web: http://climate.mssl.ucl.ac.uk
>>
>>

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Jennifer Barnes
PhD student: long range drought prediction 
Climate Extremes Group
Department of Space and Climate Physics
University College London
Holmbury St Mary 
Dorking, Surrey, RH5 6NT
Tel: 01483 204149
Mob: 07916 139187
Web: http://climate.mssl.ucl.ac.uk



More information about the R-help mailing list