[R] polygon circling a graph

William Dunlap wdunlap at tibco.com
Thu Nov 14 20:30:55 CET 2013


layout.fruchterman.reingold(g) returns a random result, so you
want to call it once and use the one return value.  Also, I think
you need to avoid the rescaling that plot.igraph does.  It looks
like you need to explicitly specify xlim and ylim if you do that,
but I may not have looked long enough at it.

   plot(g, layout=L, rescale=FALSE, xlim=range(L[,1]), ylim=range(L[,2]))
   polygon(L[temp1, ], col = "#0000FFAA")


Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com


> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf
> Of email
> Sent: Thursday, November 14, 2013 10:04 AM
> To: r-help at r-project.org
> Subject: [R] polygon circling a graph
> 
> Hi:
> 
> I want to create a polygon encircling a graph. For this i use convex
> hull  to get the coordinate points for polygon.
> 
> g <- barabasi.game(10)
> L<-layout.fruchterman.reingold(g)
> temp1 <- chull(L)
> temp1 <- c(temp1, temp1[1])
> plot(g, layout=layout.fruchterman.reingold)
> 
> 
> But when i plot the polygon with the code below, the polygon dosen't
> encircle the graph.
> 
> polygon(L[temp1, ], col = "#0000FFAA")
> 
> How can I plot a polygon circling a graph?
> 
> Regards:
> John
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list