[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [igraph] Upside-Down Trees and Vertex Size

From: Gabor Csardi
Subject: Re: [igraph] Upside-Down Trees and Vertex Size
Date: Thu, 24 Jul 2008 03:31:07 -0500
User-agent: Mutt/1.5.17+20080114 (2008-01-14)


On Wed, Jul 23, 2008 at 01:26:50PM -0700, Aaron Arvey wrote:
> Hi,
> First, thanks for the great network library!
> Second, I'm trying to create a tree similar to the one found at:
> http://en.wikipedia.org/wiki/Alternating_decision_tree
> I've figured out the basic ways of specifying attributes in R, (e.g.  
> V(g)$shape <- "rectangle"); however there are a few things that I can't  
> seem to figure out.

hmmm, you don't have to "figure out", it is documented in 

>   * I'm plotting the graph using the layout.reingold.tilford layout.
>     However, I wanted to have the root at the top instead of the bottom.
>     Is there an easy way to specify this or do I need to dig into the code
>     and create an option?

There is no need for such an option, just do something like

coords <- layout.reingold.tilford(g)
coords[,2] <- max(coords[,2])-coords[,2]

>   * I'm use larger labels than are normally used with the package.  As
>     such, I'm attempting to set the size of the node appropriately, since
>     it is not automatically resized for the given text.  I'm currently
>     using a few hacks, but nothing serious.  Does anyone have any
>     suggestions for robustly resizing vertices to be compatible with
>     arbitrary text?

1) create an empty plot
2) use strwidth() to measure the width of the text expressions
3) use 'vertex.size'*100 (nasty internal thing in igraph) and
   'add=TRUE' to plot the graph.


plot(1, type="n", axes=FALSE, xlab=NA, ylab=NA, xlim=c(-1,1), ylim=c(-1,1))
g <- graph.ring(10)
V(g)$label <- sample( c("Hi!", "Hello!", "Hello world!"), vcount(g), rep=TRUE)
sw <- strwidth(paste("", V(g)$label, ""))
sh <- max(strheight(V(g)$label))
plot(g, vertex.shape="rectangle", add=TRUE, vertex.size=sw*100,
     layout=layout.circle, vertex.size2=sh*100*2)

The paste() just leaves some space on the sides. You might need to use
layout.norm to fit your layout into the (-1,1) region.

>   * I noticed that plotting a large tree using the postscript device in R
>     gives a fairly difficult to read output (e.g plot(graph.tree(1000, 2)))
>     Is there an easy way to resize the page so that the tree can be more
>     spread out?

You can set the page size with the 'width' and 'height' options of 


ps. please consider joining the mailing list, otherwise your messages 
might be delayed because they need acknowledgement.

> Any advise is greatly appreciated!
> Thanks,
> Aaron
> _______________________________________________
> igraph-help mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/igraph-help

Csardi Gabor <address@hidden>    UNIL DGM

reply via email to

[Prev in Thread] Current Thread [Next in Thread]