Skip to content
Back to formatted view

Raw Message

Message-ID: <418A7D53.3030906@statistik.uni-dortmund.de>
Date: 2004-11-04T19:04:51Z
From: Uwe Ligges
Subject: Labelling contour lines
In-Reply-To: <Pine.LNX.4.44.0411041222360.28041-100000@red00.iridis.soton.ac.uk>

Nathaniel Street wrote:

> I am using contour to draw contour lines onto a photo (jpeg) of a leaf on 
> a white background.
> 
> I have two problems:
> 
> 1) The contour gets plotted at right angles to the jpeg image. 

I guess you either haven't realized the ordering of the y axis or you 
have created the matrix column-wise instead of row-wise (or vice versa).
I can only guess, because there is no reproducible example...


 > I guess
> this is a problem of referencing the start and end points of the image 
> matrix but I can't see how to over come this other than loading in a 
> second image that has been rotated 90 degrees and plotting the contours on 
> the non-rotated one (obviously a bad solution)

> 2) I want to be able to select a single contour after they have been 
> drawn. I know there is contourLines but I can't see how to relate this to 
> the contours plotted. In matlab there is a function to label contours so 
> that they can be called by their contour label in order to get the 
> coordinates of the contour. Can this be done in R.

Not really, what you can to is (extended from ?contour):


  x <- -6:16
  contour(outer(x, x), method = "edge", vfont = c("sans serif", "plain"))
  cL <- contourLines(outer(x, x), levels=75)
  lines(cL[[1]], col="red")

Now you have the contour lines coordinates for level 75 in cL, an 
plotted it afterwards.

Uwe Ligges


> Sorry if these are easy / stupid questions. I'm new to all this. I have 
> searched previos posts but can't find the answers I need and I would 
> rather be able to use R than matlab.
> 
> Thanks
>