I'd like to make some polar plots with R, but I can't seem to find anything designed to help with that. Is there anyway to get a real polar mode, where instead of x and y you have r and theta? How about a way to draw a circle? -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Here is quick polar scatterplot function (attached) which might give you
some ideas. This is just a sketch, but shows how to do the basics.
(It contains a number of circles.)
--
Ross Ihaka Email: ihaka at stat.auckland.ac.nz
Department of Statistics Phone: (64-9) 373-7599 x 5054
University of Auckland Fax: (64-9) 373-7018
Private Bag 92019, Auckland
New Zealand
-------------- next part --------------
# Polar coordinate plot.
# It is assumed that "r" is given in radians.
polar.plot <-
function(r, theta,
pch = NULL,
col = NULL,
angle.axis = -90)
{
## Determine the range of data value.
## Choose pretty cutpoints which include the range.
rpretty <- pretty(range(abs(r), 0, na.rm=TRUE))
rmax <- rpretty[length(rpretty)]
## Begin a new plot.
plot.new()
## Set up the plot coordinates.
## We choose a square region which includes a circle
## large enough to include all the data.
## Note the use of asp = 1, so that circles will
## appear as circles, even if a graphics window is resized.
plot.window(xlim = c(-rmax, rmax),
ylim = c(-rmax, rmax),
asp = 1)
## Draw a circular grid.
## (a) The circles are really polygons with many vertices.
## (b) The magic number "5" is choosen because a change of
## a change of direction of less than 5 degrees appears smooth.
grid <- seq(0, 2 * pi, length = 360 / 5 + 1)
for(rad in rpretty) {
if(rad > 0)
lines(rad * cos(grid), rad * sin(grid), col = "gray")
}
## Draw a radial grid in "gray".
## The use of "12" gives divisions into 30 degree slices.
rad <- seq(0, 2 * pi, length = 12 + 1)[-1]
segments(0, 0, rmax * cos(rad), rmax * sin(rad), col = "gray")
## Basic axis labelling.
## Labels appear along the ray at angle "angle.axis" to the x
axis.
text(rpretty[-1] * cos(angle.axis * pi / 180),
rpretty[-1] * sin(angle.axis * pi / 180),
rpretty[-1])
## Plot the data values - this is the easy bit.
points(r * cos(theta),
r * sin(theta),
col = col, pch = pch)
}
## Example plot for fake data
group <- sample(3, 100, replace = TRUE)
theta <- 0.5 * rnorm(100) + 0.5 * group
r <- rnorm(100, 4)
polar.plot(r, theta,
col = c("red","green4","blue")[group],
pch = 20)
Hello! Is there any way to draw a grid of coordinates on the "floor" or the "walls" of a persp plot? Or can I even add a contour to the "floor"? Thx in advance, detlef -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Try the package "scatterplot3d" Cheers P.J. On Wed, 13 Jun 2001 detlef.steuer at unibw-hamburg.de wrote:> Hello! > > Is there any way to draw a grid of coordinates on the "floor" or the "walls" of > a persp plot? > > Or can I even add a contour to the "floor"? > > Thx in advance, > > detlef > -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- > r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html > Send "info", "help", or "[un]subscribe" > (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch > _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._ >Paulo Justiniano Ribeiro Jr Dept Maths & Stats - Fylde College Lancaster University Lancaster LA1 4YF - U.K. e-mail: Paulo.Ribeiro at est.ufpr.br http://www.maths.lancs.ac.uk/~ribeiro -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._