On Mon, Jun 15, 2009 at 12:55 PM, Dominique
Manchon<manc...@math.univ-bpclermont.fr> wrote:
>
> Hello!
>
> I'm a newcomer into Sage and Python. When I want to draw some
> graphical
> representation of graphs I get problems : the vertices are partially
> cut-off. They almost disappear when the graph looks like a vertical
> ladder. For example:

Despite years of work, drawing graphs in Sage is still pretty broken.
This is very clear to anybody who uses the Sage graph code for any
amount of time.

The graph plotting works well for:

    * circular planar graphs
    * all the graphs you get by typing "graphs.<tab key>" (thanks Emily)
    * sometimes for connected graphs.

It's *terrible* for graphs with multiple components.  And for random
small graphs, as you say it chops off vertices, and generally looks
very unpolished.

My understanding is that the following work has been done on graph
plotting in Sage:

    * take the networkx graph plotting code and make it actually work from sage
    * nice layouts for everything in graphs.<tab key>
    * make it so the spring layout algorithm runs very very quickly
    * add support for loops and multiple edges (thanks emily)
    * add a layout="circular" algorithm
    * add a layout="tree" algorithm
    * lots of support for colorings (in sage-4.0.1)

It's pretty clear substantial further work is still needed.  I taught
an undergrad course last quarter using Sage, and found plotting with
anything but layout="circular" to be sort of embarrassing.  But I
didn't do anything about it.

Please -- Emily and Robert -- don't be at all offended by this email.
You two have both dramatically improved graph plotting in Sage over
what networkx offers, and Emily's predesigned layouts for the graph
families are beautiful.    I just think it is important to acknowledge
that on random input graphs plotting has a ways to go.

 -- William

>
> arbre1={0:[1],1:[]}
> arbre2={0:[1,2],1:[],2:[]}
> A1=Graph(arbre1)
> AA1=A1.plot(vertex_size=120, layout="tree",
> tree_orientation="up",tree_root=0)
> A2=Graph(arbre2)
> AA2=A2.plot(vertex_size=120, layout="tree",
> tree_orientation="up",tree_root=0)
> AA1.show(figsize=[2,2]);AA2.show(figsize=[2,2])
>
> How can I cure this?
>
> Another related question : which values are allowed for figsize[-,-]?
> Very
> often I would like quite tiny drawings (hence small values) but then I
> get
> an error message. For example the same as above with figsize=[1,1]
> returns
> the message below. Why?
>
> Thanks in advance for the help.
>
> Dominique Manchon
>
> libpng error: Image width or height is zero in IHDR
> Traceback (most recent call last):
>  File "<stdin>", line 1, in <module>
>  File "/home/sage/sagenb/sage_notebook/worksheets/manchon/4/code/
> 24.py",
> line 13, in <module>
>    AA1.show(figsize=[_sage_const_1 ,_sage_const_1
> ]);AA2.show(figsize=[_sage_const_1 ,_sage_const_1 ])
>  File
> "/home/sage/sage_install/sage/local/lib/python2.5/site-packages/
> Jinja-1.2-py2.5-linux-x86_64.egg/",
> line 1, in <module>
>
>  File
> "/home/sage/sage_install/sage/local/lib/python2.5/site-packages/sage/
> plot/plot.py",
> line 1291, in show
>    hgridlinesstyle=hgridlinesstyle)
>  File
> "/home/sage/sage_install/sage/local/lib/python2.5/site-packages/sage/
> plot/plot.py",
> line 1616, in save
>    canvas.print_figure(filename, dpi=dpi)
>  File
> "/home/sage/sage_install/sage/local/lib/python2.5/site-packages/
> matplotlib/backend_bases.py",
> line 1453, in print_figure
>    **kwargs)
>  File
> "/home/sage/sage_install/sage/local/lib/python2.5/site-packages/
> matplotlib/backends/backend_agg.py",
> line 334, in print_png
>    filename_or_obj, self.figure.dpi)
> RuntimeError: Error building image
>
> >
>



-- 
William Stein
Associate Professor of Mathematics
University of Washington
http://wstein.org

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to