How do I pass arguments to pygraphviz "neato"?

2,413 views
Skip to first unread message

Brian Feeny

unread,
Nov 4, 2013, 12:44:20 PM11/4/13
to networkx...@googlegroups.com
I am currently using the neato layout from pygraphviz, and that works well.  But I would like to pass arguments for overlap=false or sep=+1, etc.

i tried like so:

pos = nx.graphviz_layout(votes,prog="neato", args='overlap=false')

that does not appear to work, and I could not find examples on the NetworkX homepage which showed using any pygraphviz additional arguments.

Aric Hagberg

unread,
Nov 4, 2013, 4:57:29 PM11/4/13
to networkx...@googlegroups.com
That looks correct.
Are you using pygraphviz or pydot do do the layout?
The pygraphviz code is in nx_agraph and the pydot in nx_pydot. It
could be the pydot layout doesn't handle extra arguments.

Aric
> --
> You received this message because you are subscribed to the Google Groups
> "networkx-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to networkx-discu...@googlegroups.com.
> To post to this group, send email to networkx...@googlegroups.com.
> Visit this group at http://groups.google.com/group/networkx-discuss.
> For more options, visit https://groups.google.com/groups/opt_out.

Brian Feeny

unread,
Nov 4, 2013, 11:36:17 PM11/4/13
to networkx...@googlegroups.com
I am using pygraphviz, I got it to work doing like so:

pos = nx.graphviz_layout(mst_bipartisan,prog="circo", args="-Goverlap=false" )

so now I am wondering what is the syntax for wanting to include more than one argument?  I tried some syntaxes using commas or semi-colons I got some errors, I wonder if correct is doing like so:

pos = nx.graphviz_layout(mst_bipartisan,prog="circo", args="-Goverlap=false -Gsize=24,24!" )

Does anyone know?

Aric Hagberg

unread,
Nov 5, 2013, 9:15:18 AM11/5/13
to networkx...@googlegroups.com
Your example should work. You can see what global attributes are
being set by converting to a pygraphviz (graphviz agraph) data
structure and inspecting the results:

In [1]: import networkx as nx

In [2]: G = nx.Graph([(1,2)])

In [3]: A = nx.to_agraph(G)

In [4]: A.layout(args="-Goverlap=false -Gsize=12,12!" )

In [5]: print A
strict graph {
graph [bb="0,0,127.21,49.639",
overlap=false,
size="12,12!"
];
node [label="\N"];
1 [height="0.51389",
pos="28,30.139",
width="0.75"];
2 [height="0.51389",
pos="99.21,19.5",
width="0.75"];
1 -- 2 [pos="54.516,26.177 60.368,25.303 66.572,24.376 72.434,23.5"];
}

Aric

Brian Feeny

unread,
Nov 5, 2013, 3:13:31 PM11/5/13
to networkx...@googlegroups.com
thanks, just what I needed
Reply all
Reply to author
Forward
0 new messages