s-news
[Top] [All Lists]

Re: Windows line plotting

To: Thom Burnett <Thom.Burnett@cognigencorp.com>
Subject: Re: Windows line plotting
From: David L Lorenz <lorenz@usgs.gov>
Date: Thu, 28 Jul 2005 09:46:41 -0500
Cc: S-News <s-news@lists.biostat.wustl.edu>, s-news-owner@lists.biostat.wustl.edu
In-reply-to: <42E7DB70.7040407@cognigencorp.com>

Thom,
  I have also found this to be a troubling characteristic of the GUI graphics. Plotting a large number of points is fast and easy, but wanting specialized treatments by groups is difficult and sometimes very slow. You can break the lines by writing a user function to smooth the data. Here's one that works for a 2D plot. It does not smooth the data, but does insert breaks when brk (the id) changes.

breaklines <- function(x,y,z, brk, ...) {
 xs <- tapply(x, brk, function(x) c(x,NA))
 ys <- tapply(y, brk, function(x) c(x,NA))
 return(list(x=unlist(xs), y=unlist(ys)))
}

  The z argument is ignored, but conceivably could be used in a 3-D plot. In the Line/Scatterplot menu dialog window, on the Smooth/Sort page, select Smoothing type User, enter breaklines in the Function Name box, and brk=DF$id in the Other Arguments box, where DF is the name of the data frame. Then press the Apply button. Of course this must be after the breaklines function has been sourced.
Dave
<Prev in Thread] Current Thread [Next in Thread>