Hello, Thanks for the answer!
I had no success using the layout's bounding box as the value for my plot's bbox parameter, because I could only see a few nodes on the left edge of my rendered pdf or svg. I think this might be because my layout's bounding box has a negative first element? It was BoundingBox(-926.5, 1.0, 13.0, 5097.0). I set the bbox manually and used a huge width of 40000 and the nodes weren't on top of each other any more. However, when plotting I see some strange artifacts that were not visible when exporting to dot format and using Graphviz's dot renderer (which is similar to Sugiyama) : I wouldn't really know how to explain it so here is a screenshot : http://i.imgur.com/hhZz5v7.png Those artifacts are also visible when using a smaller bbox width and the nodes are on top of each other. I tried using a bigger number of iterations (10k now) but it doesn't seems to have an effect. Thank you, and have a good day! On Fri, Mar 29, 2013 at 3:07 AM, Tamás Nepusz <[email protected]> wrote: > Hello, > > > However, it seems that it doesn't take into account the hgap property, > which should set the "minimum horizontal gap between vertices in the same > layer", according to the documentation. > It does take the hgap property into account, the problem is that > igraph.plot() will rescale your layout to fill the specified bounding box > and it does not strive to keep the aspect ratio the same. To prove that > layout_sugiyama() indeed uses the hgap parameter, try this: > > >>> g = Graph.Tree(4, 3) > >>> layout_1 = g.layout_sugiyama(hgap=1) > >>> print list(layout_1) > [[1.0, 0.0], [0.0, 1.0], [1.0, 1.0], [2.0, 1.0]] > >>> layout_2 = g.layout_sugiyama(hgap=10) > >>> print list(layout_2) > [[10.0, 0.0], [0.0, 1.0], [10.0, 1.0], [20.0, 1.0]] > > The only solution I can think of is to take the layout, get its bounding > box using the bounding_box() method of the layout itself and then specify > the bbox parameter of igraph.plot to be proportional to the dimensions of > the layout's bounding box (and don't forget to set margin=0 or take the > margin into account when invoking igraph.plot()). Yes, I agree that this > sucks. I will add a keep_aspect_ratio option to the default graph drawer > class in the next version. > > If you are willing to modify igraph's source code a bit, you can also work > around the issue as follows: > > 1. Open igraph/drawing/graph.py from igraph's source code -- this contains > the DefaultGraphDrawer class, which is used for graph drawing. > > 2. Find the line that looks like this: > > layout.fit_into(bbox, keep_aspect_ratio=False) > > 3. Replace the line with the following: > > layout.fit_into(bbox, keep_aspect_ratio=kwds.get("keep_aspect_ratio", > False)) > > Then you can simply say igraph.plot(g, "graph.pdf", layout=layout, > keep_aspect_ratio=True). > > > It also seems that the weights property ("edge weights to be used") > wasn't taken into account when I tried it, passing a list with the weight > for each layer. > The weights are taken into account only in the cycle-breaking phase: since > the Sugiyama layout requires a directed acyclic graph, it will temporarily > break all the cycles by trying to remove a set of edges whose total weight > is minimal. > > -- > T. > _______________________________________________ > igraph-help mailing list > [email protected] > https://lists.nongnu.org/mailman/listinfo/igraph-help >
_______________________________________________ igraph-help mailing list [email protected] https://lists.nongnu.org/mailman/listinfo/igraph-help
