[R] Annotate a levelplot (using abline) - Difficulty with trellis.
skiadas at hanover.edu
Wed Apr 4 14:25:02 CEST 2007
On Apr 4, 2007, at 7:19 AM, Dan Bolser wrote:
> 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!)...
> 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;
> Thanks for any help !
Department of Mathematics and Computer Science
More information about the R-help