[R] my.symbols and zoomplot functions now available in TeachingDemos package
Greg Snow
Greg.Snow at intermountainmail.org
Tue Apr 17 16:59:24 CEST 2007
In February (2/26) Jonathan Lees asked a question about plotting symbols
whose shape/aspect ratio is independent of of the user coordinate
system. A couple of other posts have also been made asking about
plotting symbols of a given fixed size/aspect ratio.
The latest version of the TeachingDemos package (1.5) now has a function
called my.symbols that is similar to the symbols function except that it
allows you to specify your own symbols. Your symbol can be a matrix or
list with x and y coordinates (on the range -1, 1) that specify the
shape of the symbol (to be connected with lines), or it can be a
function (additional arguments are passed to this function) that plots
your symbol. The my.symbols function will then place your symbols at
the designated x,y coordinates at the specified size with the aspect
ratio independent of the user coordinates. Some example symbol
functions are also provided and the help page shows several examples of
potential uses. Hopefully others will find this useful.
There have also been several questions recently about changing the range
of a plot after the plot has been created. TeachingDemos now also
contains a function zoomplot that will do this (either zooming into a
section of the existing plot, or zooming out to show parts that were
previously clipped). This function is a quick and dirty hack and should
not replace properly defining the ranges for serious graphs, but may be
helpful for quick exploring.
On a similar note, there is also a new function (plot2script) for
creating a script file to recreate the current plot that can then be
editted and rerun to make minor changes.
These functions have only been tested on windows (R versions 2.4.1 and
2.5.0beta), so I would appreciate if someone could try them on other
platforms and let me know if they work or not.
Hope these are useful to others out there,
--
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at intermountainmail.org
(801) 408-8111
More information about the R-help
mailing list