That's a great suggestion.  I'm not familiar at all with the doc test 
extension, so the plot directive doesn't do this.  It gets a fresh 
namespace (though not a fresh interpreter) for each plot.

To avoid complicating the merge further, I'd like to wait for Pauli 
Vertanen's merge of the new plot directive features from Numpy back into 
matplotlib before looking at implementing this.  It will probably just 
involve inheriting/emulating whatever the doctest extension is doing to 
make that work.  And if the directive is used in the old way (providing 
a filename), we'll just clear any state at that point.

Mike

Matthew Brett wrote:
> Hi guys,
>
>   
>> You can now do:
>>
>> .. plot::
>>
>>     from matplotlib.pyplot import *
>>     plot([1,2,3])
>>     
>
> This is very nice - thank you for doing that.
>
> But, thinking about the online tutorials, you often want to do
> something as you can do with the sourcecode directive, as in:
>
> .. testcode::
>
>    import numpy as np
>    print np.inf
>
> Some text then
>
> .. testoutput::
>
>    inf
>
> More text
>
> .. testcode::
>
>    # I still have the context from the blocks above
>    print np.nan
>
> More text
>
> .. testoutput::
>
>    nan
>
>
> In that way, I can build up a tutorial, setting and calculating
> variables, doing plots as I go, without having to recreate the
> calculations at each step.
>
> Is it possible to make the ..plot directive pick up the context in the same 
> way?
>
> Thanks a lot,
>
> Matthew
>   

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


------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

Reply via email to