plot directive in reST tutorials

Mon, 16 Feb 2009 10:30:47 -0500, Michael Droettboom wrote:

A preliminary version of this is committed on the branch and trunk.

You can now do:

.. plot::

     from matplotlib.pyplot import *
     plot([1,2,3])

One open API question is whether to implicitly "from matplotlib.pyplot
import *" or "from matplotlib import pyplot as plt" or nothing. I
generally don't like "import *" or implicit things, so I've decided to
do none of the above. But I could see how it might be nice to reduce
the verbosity of these little code examples to import something be
default. Let me know if you feel strongly about changing it.

It has also been moved to the installed source directory, so other
projects no longer need to copy it. Just change the entry in the
extensions list in the Sphinx conf.py from 'plot_directive' to
'matplotlib.sphinxext.plot_directive' and remove your local copy of the
extension.

Scipy's plot directive has had this feature for some time:
  
  http://svn.scipy.org/svn/numpy/trunk/doc/sphinxext/plot_directive.py

plus some extra features. I think it should contain all the features in
matplotlib's version; but OTOH, I haven't tried to build matplotlib docs
using it.

I think we really should merge it back *now*!
(Re: Gael's thread; sorry, I've been lazy pushing the changes back...)

The "official" version of the plot directive should IMO end up either
in Sphinx or matplotlib repository. It's probably OK to require matplotlib
SVN version to build Scipy docs for a while...

What do you think?

···

--
Pauli Virtanen

Pauli Virtanen wrote:

Mon, 16 Feb 2009 10:30:47 -0500, Michael Droettboom wrote:

A preliminary version of this is committed on the branch and trunk.

You can now do:

.. plot::

     from matplotlib.pyplot import *
     plot([1,2,3])

One open API question is whether to implicitly "from matplotlib.pyplot
import *" or "from matplotlib import pyplot as plt" or nothing. I
generally don't like "import *" or implicit things, so I've decided to
do none of the above. But I could see how it might be nice to reduce
the verbosity of these little code examples to import something be
default. Let me know if you feel strongly about changing it.

It has also been moved to the installed source directory, so other
projects no longer need to copy it. Just change the entry in the
extensions list in the Sphinx conf.py from 'plot_directive' to
'matplotlib.sphinxext.plot_directive' and remove your local copy of the
extension.
    
Scipy's plot directive has had this feature for some time:
  
  http://svn.scipy.org/svn/numpy/trunk/doc/sphinxext/plot_directive.py

plus some extra features. I think it should contain all the features in
matplotlib's version; but OTOH, I haven't tried to build matplotlib docs
using it.
I think we really should merge it back *now*!
(Re: Gael's thread; sorry, I've been lazy pushing the changes back...)
  

We've clearly all been bad about forking this stuff all over the place. I was completely unaware it was being used for Scipy. It's unfortunate the suggestion to install this stuff as part of matplotlib wasn't made earlier.

Anyway, the current version in matplotlib handles files in a way that behaves well with Sphinx (which I see is a TODO list item in the numpy version). It also uses the Sphinx extension API rather than the old and brittle way of defining directives etc. So those things will need to be merged with the other changes made on the Numpy side.

The "official" version of the plot directive should IMO end up either
in Sphinx or matplotlib repository. It's probably OK to require matplotlib
SVN version to build Scipy docs for a while...
  

I think it makes the most sense for this to be part of matplotlib, since it fundamentally requires matplotlib -- that prevents Sphinx from growing a matplotlib dependency.

Mike

···

--
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA

Yeah, I am +1 for that too.

Thank you for exposing the plot_directive in the MPL importable tree,
Michael. It is going to take a little while for a new MPL release to
trickle down to enough installed computers for people to be abe to throw
away their local copy, but this is clearly the good solution.

Gaël

···

On Mon, Feb 16, 2009 at 01:26:40PM -0500, Michael Droettboom wrote:

> The "official" version of the plot directive should IMO end up either
> in Sphinx or matplotlib repository. It's probably OK to require matplotlib
> SVN version to build Scipy docs for a while...

I think it makes the most sense for this to be part of matplotlib, since
it fundamentally requires matplotlib -- that prevents Sphinx from
growing a matplotlib dependency.