s-news
[Top] [All Lists]

Re: Plotting from within a function

To: S-News <s-news@wubios.wustl.edu>
Subject: Re: Plotting from within a function
From: Kim Elmore <Kim.Elmore@noaa.gov>
Date: Fri, 02 Mar 2007 13:47:57 -0600
My thanks to everyone for your replies!

The trick I needed is to wrap plot() within print(), so the result will resemble print(plot(...)).

As an aside, I am also plotting more complex objects: I'm using map() (from the S-Plus maps library), image() and contour(). It turns out that these functions need not be wrapped within print(). In fact, doing so forces a lot of extraneous output that I can't seem to suppress with invisible(). However, if my function resembles

my.plot.map <- function(...) {
   ...
   print(plot(...))
   ...
   map(...)
   image(...)
   map(...)
   contour(...)
   ...
   invisible()
}

then all is well! Note that the last invisible() is needed to prevent extraneous output from map() in particular and contour() to a lesser extent.

Kim Elmore
                          Kim Elmore, Ph.D.
                       University of Oklahoma
        Cooperative Institute for Mesoscale Meteorological Studies
"All of weather is divided into three parts: Yes, No, and Maybe. The
greatest of these is Maybe" The original Latin appears to be garbled.


<Prev in Thread] Current Thread [Next in Thread>
  • Re: Plotting from within a function, Kim Elmore <=