splines = ortho is not working fine when used with draw in PyGraphviz

1,502 views
Skip to first unread message

Animesh Kumar

unread,
Aug 7, 2015, 7:45:05 PM8/7/15
to pygraphviz-discuss
Hi,

I am creating my graph with splines = ortho. The issue I am facing is that when I generate a dot file and View it with the Graphviz app, the graph comes alright with the orthogonal lines.
But when I generate a SVG or PDF or PNG version of my graph using various layouts, my graph doesn't make orthogonal lines in the SVG, PDF or PNG format.

I used the following settings for the graph :- 


                lldp_neighbours_graph = AGraph(strict = False, directed = True, overlap = "scale", splines="ortho", nodesep="0.5", rankdir = "LR")
# Set the style attributes of the graph
lldp_neighbours_graph.node_attr['style']='rounded'
lldp_neighbours_graph.node_attr['shape']='box'
lldp_neighbours_graph.node_attr['fixedsize']='false'
lldp_neighbours_graph.node_attr['labelloc']='c'
lldp_neighbours_graph.node_attr['fontname']='times'
lldp_neighbours_graph.node_attr['fontcolor']='purple'
lldp_neighbours_graph.node_attr['sep']='5'

lldp_neighbours_graph.add_edge(source,destination,key=key_str,dir='both', headlabel=remote_port, taillabel=local_port, style='bold',color='blue', minlen=5)

# Resize all the nodes based on the number of incoming and outgoing nodes edges
for node in lldp_neighbours_graph.nodes():
if edge_count[node] > 0:
node.attr['height'] = 0.6 * edge_count[node] #I maintain a count of edges and this logic works fine
node.attr['width'] = 0.6 * edge_count[node]
else:
node.attr['height'] = 2
node.attr['fontcolor'] = 'orange'





# Write the graph to a dot file
graph.write('graph.dot') # write to simple.dot  



My Code for generating SVG file :-

#neato, dot, twopi, circo, fdp, nop, wc, acyclic, gvpr, gvcolor, ccomps, sccmap, tred, sfdp.
# Write the graph to a SVG file
graph.draw('graph.svg',prog='dot',args='-Gsplines=ortho') 

I have tried with all the layouts mentioned in the comment and none of them gave me any different results.
What am I doing wrong here?

How is graphviz app being able to view my dot file properly whereas my code fails to generate a proper image or SVG or PDF version of it.

You can have a look at my DOT file (view in Graphviz App), SVG and PDF version to know what I mean.

Link to my DOT file :- 

And this is how it looks with the GraphViz app, I have exported it to PDF using the Graphviz App renderer 'Quartz' and it just looks what I want.

But the SVG or PDF generated by the Python code looks nothing like the above two :(

Please help if I am doing something wrong. 


Aric Hagberg

unread,
Aug 7, 2015, 8:11:28 PM8/7/15
to pygraphvi...@googlegroups.com
I'm not sure what the problem is. When I do this

In [1]: import pygraphviz

In [2]: g = pygraphviz.AGraph('cd

In [2]: g = pygraphviz.AGraph('cdbu.dot')

In [3]: g.draw('graph.svg',prog='dot',args='-Gsplines=ortho')

I get the same picture as your 'correct' drawing. Perhaps there is
some issue with the graphviz version that is being called by graphviz?
It may not be the same one as the Graphviz.app program.

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

Animesh Kumar

unread,
Aug 7, 2015, 9:03:40 PM8/7/15
to pygraphviz-discuss
I just tried the same importing my dot and rendering it like you have done it and got the incorrect drawing only. 

When I do dot -V,

I get "dot - Graphviz version 2.14.1".

Can this be a problem?

I earlier had installed graphviz development version 2.36 (graphviz-2.36.0.pkg) from 
and now installed a 2.38 version (graphviz-2.38.0.pkg) but facing the same issue even now.

Can you tell me what graphviz and pygraphviz version are you using and where can i download them from, since it's working correctly in your versions?

Aric Hagberg

unread,
Aug 8, 2015, 11:54:49 AM8/8/15
to pygraphvi...@googlegroups.com
I'm using graphivz-2.36.0 and the latest pygraphviz version 1.3rc2.
Pygraphviz should be running the command
dot -Gsplines=ortho cblue.dot -Tsvg > graph.svg
so if that doesn't work for you from the command line it is a graphviz problem.

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

Animesh Kumar

unread,
Aug 8, 2015, 6:43:02 PM8/8/15
to pygraphviz-discuss
I just tried the above command and got the incorrect drawing. So maybe my graphviz has the bug.
When I do:-  
graphviz -V

I get "dot - Graphviz version 2.14.1". 
Why does my graphviz version show 2.14 even though I have installed 2.38 version of it?

Can you tell me where can I get graphviz version 2.36 for Mac OS since I have installed graphviz (currently 2.38 and earlier 2.36) from here :-


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

Aric Hagberg

unread,
Aug 10, 2015, 12:59:35 PM8/10/15
to pygraphvi...@googlegroups.com
Something is wrong with your graphviz search path I guess so you are
getting an old version.
I'm using Linux so not sure which is the right OSX solution.
Downloading from graphviz.org sounds good.

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

Animesh Kumar

unread,
Aug 12, 2015, 5:04:34 PM8/12/15
to pygraphviz-discuss
Hi,

I just fixed my graphviz version and now it's pointing to graphviz 2.36.
Now the graphviz and pygraphviz are generating SVG images properly and as intended.

In version 2.36, the graph generations work fine for various output formats but i get a warning printed

/Library/Python/2.7/site-packages/pygraphviz/agraph.py:1332: RuntimeWarning: Aug 12 13:58:21 animeshk-mbp dot[51364] <Error>: The function CGFontGetGlyphPath is obsolete and will be removed in an upcoming update. Unfortunately, this application, or a library it uses, is using this obsolete function, and is thereby contributing to an overall degradation of system performance.


Aug 12 13:58:21 animeshk-mbp dot[51364] <Error>: The function CGFontGetGlyphPaths is obsolete and will be removed in an upcoming update. Unfortunately, this application, or a library it uses, is using this obsolete function, and is thereby contributing to an overall degradation of system performance.




  warnings.warn(b"".join(errors), RuntimeWarning)



How can i get rid of this warning?


Also, I saw a bug in 2.38 version, my pdf and png generation code, which works in 2.14 and 2.36 had started failing in 2.38.

I am using the following code :-

graph.draw("graph",prog='dot')

and it fails with the following errors :-

  File "../script/lldp_network.py", line 300, in write_graph


    graph.draw("graph",prog='dot')


  File "/Library/Python/2.7/site-packages/pygraphviz/agraph.py", line 1468, in draw


    data = self._run_prog(prog, args)


  File "/Library/Python/2.7/site-packages/pygraphviz/agraph.py", line 1329, in _run_prog


    raise IOError(b"".join(errors))


IOError: dyld: lazy symbol binding failed: Symbol not found: _pixman_region32_init


  Referenced from: /usr/local/lib/graphviz/libgvplugin_pango.6.dylib


  Expected in: flat namespace




dyld: Symbol not found: _pixman_region32_init


  Referenced from: /usr/local/lib/graphviz/libgvplugin_pango.6.dylib


  Expected in: flat namespace




What can be the issue?

On doing dot -V, I get the following :-

dot - graphviz version 2.38.0 (20140413.2041)


libdir = "/usr/local/lib/graphviz"


Activated plugin library: libgvplugin_dot_layout.6.dylib


Using layout: dot:dot_layout


Activated plugin library: libgvplugin_core.6.dylib


Using render: dot:core


Using device: dot:dot:core


The plugin configuration file:


        /usr/local/lib/graphviz/config6


                was successfully loaded.


    render      :  cairo dot fig map pic pov ps quartz svg tk vml xdot


    layout      :  circo dot fdp neato nop nop1 nop2 osage patchwork sfdp twopi


    textlayout  :  textlayout


    device      :  bmp canon cgimage cmap cmapx cmapx_np dot eps exr fig gif gv icns ico imap imap_np ismap jp2 jpe jpeg jpg pct pdf pic pict plain plain-ext png pov ps ps2 psd sgi svg svgz tga tif tiff tk vml vmlz x11 xdot xdot1.2 xdot1.4 xlib


    loadimage   :  (lib) bmp eps gif jpe jpeg jpg pdf png ps svg




>> >> > To post to this group, send email to pygraphvi...@googlegroups.com.
>> >> > Visit this group at
>> >> > http://groups.google.com/group/pygraphviz-discuss.
>> >> > For more options, visit https://groups.google.com/d/optout.
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> > Groups
>> > "pygraphviz-discuss" group.
>> > To unsubscribe from this group and stop receiving emails from it, send
>> > an
>> > To post to this group, send email to pygraphvi...@googlegroups.com.
>> > Visit this group at http://groups.google.com/group/pygraphviz-discuss.
>> > For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups
> "pygraphviz-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
Reply all
Reply to author
Forward
0 new messages