Re: [R] Annotate a levelplot (using abline) - Difficulty with trellis.

From: Charilaos Skiadas <skiadas_at_hanover.edu>
Date: Wed 04 Apr 2007 - 12:25:02 GMT

On Apr 4, 2007, at 7:19 AM, Dan Bolser wrote:

> Hi,
>
> I am generating a beautiful plot with the 'levelplot' function over my
> square matrix of data. In order to help visualise the data I would
> like to draw a diagonal line on the matrix. Because the plot is
> actually a trellis object, I am having difficulty working out how to
> do this. I have been reading around, but I don't see any easy solution
> to the problem. (Most of the docs I have found are not of the type
> 'how to do it' but more like 'how to grok it'). After spending 1+ hour
> reading and trying various things I figure its time to ask some people
> who know ;-)
>
> So far I have the following (which almost works!)...
>
> levelplot(
> our.data,
> plot.xy = (abline(0,1,col="white"))
> )

  1. Please always provide a reproducible example.
  2. Normal drawing commands, like abline, can't be used in trellis graphics, and vice versa.
  3. Look into ?panel.functions, in particular panel.abline. My understanding is that this is how you customize a graph, providing your own panel function which calls other panel functions or direct grid drawing commands.

Hope this helps.

> However the coordinate system / plot area being used are clearly not
> those of the square matrix. I guess I should point out that the axes
> of 'our.data' (the row and column names of the square matrix) are
> ordered categories of the form;
>
> seq(2,9,0.5)
>
>
> Thanks for any help !
>
> Dan.

Haris Skiadas
Department of Mathematics and Computer Science Hanover College



R-help@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 and provide commented, minimal, self-contained, reproducible code. Received on Wed Apr 04 22:30:55 2007

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Wed 04 Apr 2007 - 13:31:00 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.