Everything is possible, some things are just more difficult than others.  It is a 
little
tricky to find the point of intersection of the voronoi edges with the frame of the
diagram.  Your basic request is quite straightforward though.  Here is a function
that plots, by looping through the sites and using voronoi.findvertices() to
get the vertices of the polygons.  In the function fit represents a z coordinate
that indicates the value of a fitted function at each of the sites, -- this may
be irrelevant in your setup.  I hope that it will help:

"plot.voronogram" <-
function (x,y,fit)
{
tm <- tri.mesh(x,y)
xlim <- c(min(tm$x) - 0.1 * diff(range(tm$x)), max(tm$x) + 0.1 * diff(range(tm$x)))
ylim <- c(min(tm$y) - 0.1 * diff(range(tm$y)), max(tm$y) + 0.1 * diff(range(tm$y)))
plot.new()
plot.window(xlim = xlim, ylim = ylim, "")
n <- length(x)
vm <- voronoi.mosaic(x,y)
palette(topo.colors(100))
cfit <- 100*fit
for(i in 1:n){
        vpolygon <- voronoi.findvertices(i,vm)
        if(length(vpolygon)){
                xx <- vm$x[vpolygon]
                yy <- vm$y[vpolygon]
                inhull <- in.convex.hull(tm,xx,yy)
                polygon(xx[inhull],yy[inhull] ,col=cfit[i])
                }
        }
}


url:    www.econ.uiuc.edu/~roger/my.html        Roger Koenker
email   [EMAIL PROTECTED]                       Department of Economics
vox:    217-333-4558                            University of Illinois
fax:    217-244-6678                            Champaign, IL 61820

On Thu, 18 Dec 2003, Klemens Barfus wrote:

> Dear List-Members,
> my name is Klemens Barfus and I am quite new to this list and to working
> with R.
> I try to generate Vornoi-Polygons with the Tripack package. I would like to
> have a table with the sites xy and the surrounding nodes of the
> Voronoi-Polygons. The area shall be delimited by a defined rectangle so that the 
> polygons
> at the edge are cut by the rectangle sides.
> Is there a way to do this ? Looking the old list entries I found no help.
> First  using voronoi.mosaic worked fine, but how to get the connection of
> the sites to the surrounding nodes. The other question is what the information
> of the voronoi.findrejectsites() functon is.  For my testdata it showed 3
> sites which ly at the edge, but it should be 6. ...
>
> Thanks for your help in advance !
>
> Klemens
>
>
> --
>
> ______________________________________________
> [EMAIL PROTECTED] mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
>

______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help

Reply via email to