From: Ted Freeman <freeman_at_u.washington.edu>

Date: Thu 05 Jan 2006 - 08:20:47 EST

polygon(x, z, col = 'green')

R-help@stat.math.ethz.ch mailing list

https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Thu Jan 05 08:59:20 2006

Date: Thu 05 Jan 2006 - 08:20:47 EST

I'm new to R, after many years of using Matlab. I've found the R
function 'polygon' to be nearly equivalent to the Matlab function
'patch'. For example, the R commands:

plot(c(0, 5), c(0, 4), type = 'n', asp = 1, ann = FALSE) x <- c(1, 2, 2, 1.5, 1) z <- c(1, 1, 2, 1.7, 2)

polygon(x, z, col = 'green')

produce a plot with a small green shape exactly as I expect. A nearly identical plot can be made in Matlab with these commands:

x = [1, 2, 2, 1.5, 1];

z = [1, 1, 2, 1.7, 2];

patch(x, z, 'g')

axis([0, 5, 0, 4])

box on

In Matlab I am able to extend this quite easily to a three-dimensional plot by simply adding one more vector argument to 'patch'. I don't see how to do this in R using 'polygon'. (I've primarily looked at scatterplot3d.) Is there another function I can use?

Since I expect that many of you do not use Matlab, I've put two graphics showing the example above (Plot 1) and a similar three-dimensional plot (Plot 2) on this page: http://staff.washington.edu/freeman/patch.html.

It's Plot 2 that I'd like to be able to reproduce in R.

Thanks for any advice!

- Ted

R-help@stat.math.ethz.ch mailing list

https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Thu Jan 05 08:59:20 2006

*
This archive was generated by hypermail 2.1.8
: Fri 03 Mar 2006 - 03:41:50 EST
*