Plotsssss' in the Docsssss'

87 views
Skip to first unread message

Nathann Cohen

unread,
Dec 14, 2014, 12:26:35 AM12/14/14
to Sage devel
Hellooooooo everybody !

On the "What can't we do ?" thread it was raised that our html
documentation did not contain many pictures.

It is true.

With the new ticket #17498, however, it becomes possible. The
following code displays a drawing of Petersen's graph

.. plot::

from sage.graphs.graph_generators import graphs
draw(graphs.PetersenGraph())

What I do not like:

- I have found no way to make the first line unecessary. It should be
useless, as 'graphs' is in Sage's global namespace. Right now you have
to explicitly import everything you use.

- I had to define a 'draw' function (see the patch). It is rather
dirty, but I found no cleaner way to do this either.

- The picture has a large white margin around it, but perhaps somebody
who knows how to use matplotlib ( I really don't ) may know how to fix
that.

On the bright side, regardless of how these points will be fixed or
ignored, we can easily add pictures to the doc :-P

Nathann

http://trac.sagemath.org/ticket/17498

Harald Schilly

unread,
Dec 14, 2014, 7:54:01 AM12/14/14
to sage-...@googlegroups.com


On Sunday, December 14, 2014 6:26:35 AM UTC+1, Nathann Cohen wrote:
- The picture has a large white margin around it...

My first thought without testing anything:

plt.tight_layout()

 which might not do much, but it has some options to try:

http://matplotlib.org/users/tight_layout_guide.html

-- H

Volker Braun

unread,
Dec 14, 2014, 8:13:17 AM12/14/14
to sage-...@googlegroups.com
On Sunday, December 14, 2014 6:26:35 AM UTC+1, Nathann Cohen wrote:
- I have found no way to make the first line unecessary. It should be
useless, as 'graphs' is in Sage's global namespace. Right now you have
to explicitly import everything you use.

The sphinx is written in plain python. Have you tried from sage.all_cmdline import * in the plot_pre_code?

Nathann Cohen

unread,
Dec 14, 2014, 8:59:13 AM12/14/14
to Sage devel
Hello !

> plt.tight_layout()
> Have you tried from sage.all_cmdline import * in the plot_pre_code?

Both work ! Branch updated on #17498. Thanks :-)

Nathann
Reply all
Reply to author
Forward
0 new messages