On 27/09/2010 11:11 AM, Czerminski, Ryszard wrote:> Is there an easy way to control smoothness of the contour lines?
>
> In the plot I am working on due to the undersampling the contour
> lines I am getting are jugged, but it is clear "by eye" these
should
> be basically straight lines.
Straight lines should come out straight in our current scheme. I
suspect your data contains rounding error or other noise, so the actual
contours aren't straight.
Curves are currently an issue: the contouring scheme will generate
polygonal contours. If the grid you pass is too coarse, you'll see it.
For example,
> x <- 1:5
> y <- 1:5
> z <- outer(x, y, function(x,y) (x-2)^2 + (y-3)^2)
> contour(x,y,z)
gives ugly contours. The solution to this problem is to use a finer grid:
> x <- seq(1, 5, len=20)
> y <- seq(1, 5, len=20)
> z <- outer(x, y, function(x,y) (x-2)^2 + (y-3)^2)
> contour(x,y,z)
makes them look quite smooth. So for your problem, I'd fit a nice
smooth model to your data, then evaluate it on a fine grid, and you'll
get nice smooth contours.
Duncan Murdoch
> In maps package I found smooth.map function, but maybe there is a more
> generic way
> of accomplishing the same thing.
>
> Ideally there would be an option to control smoothness of the contour
> lines
> in contourplot(), or levelplot(), but I cannot find a way to do it.
>
> Best regards,
>
> Ryszard Czerminski
> AstraZeneca Pharmaceuticals LP
> 35 Gatehouse Drive
> Waltham, MA 02451
> USA
> 781-839-4304
> ryszard.czerminski at astrazeneca.com
>
>
> --------------------------------------------------------------------------
> Confidentiality Notice: This message is private and may ...{{dropped:11}}
>
> ______________________________________________
> R-help at r-project.org 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.