Hi Sebastien,

Sorry, I had forgotten about that.  I've taken a look at the code that we have 
... and it doesn't separate out nearly as much as I had thought.  The code that 
rebuilds the plots is actually pretty complicated and messy ... not so much 
from a conceptual point of view but in how it was implemented.  Plus, our data 
structure and corresponding plot structure is very nested: we have a the 
concept of series in series groups, which are on plots, which are in plot 
groups, and so on up to a few levels of grouping.  Additionally, our plots 
allow for up to 4 'y' axes and 2 'x' axes, making the code seem more 
complicated than it is.

When we want to store the plots, we pickle the top object (which we call our 
plot manager) and because of the tree-like data structure, it pickles 
everything right down to the data in the series.  We've been very careful to 
ensure that there are no mpl objects referenced in the data structure.

When we unpickle the plot manager, we walk our way through the tree, calling 
plotPanel.addPlot(...) and plotPanel.addSeries(...) as we go.  In this case, 
plotPanel is a class that is a wx.Frame (well, an MDI frame in our case) that 
has a mpl figure on it, and various methods that know how to manipulate the 
data from our Plot and Series objects to create appropriate mpl analogues.  
This is strictly a one-way operation: we always build plots and series from our 
own objects and any modifications occur on our objects and not on the mpl 
lines/figures/etc.  That is, if we want to change a series colour for example, 
the code modifies our Series object and it emits a pubsub message that causes 
the plotPanel to update itself based on what's in the Series object ... we 
never manipulate the mpl line directly.

At any rate, I've attached some code to this email which illustrates what I was 
talking about, but it's not runnable and it references other files which I 
haven't included.  Still you should be able to get the idea.

Hope this helps,
Anthony.


> -----Original Message-----
> From: Sebastien Binet [mailto:[EMAIL PROTECTED] 
> Sent: October 8, 2008 9:47 PM
> To: Anthony Floyd
> Cc: Anthony Floyd
> Subject: Re: [Matplotlib-users] save or pickle figure object
> 
> Hi Anthony,
> 
> On Tuesday 16 September 2008 20:30:26 Anthony Floyd wrote:
> > On Tue, Sep 16, 2008 at 8:17 PM, Sebastien Binet
> >
> > <[EMAIL PROTECTED]> wrote:
> > > Hi Anthony,
> > >
> > >> As you've already been told, you can't pickle/shelve mpl 
> objects.  Our
> > >> solution to this is to have a native python shadow object that
> > >> contains all the bits and pieces needed to create a 
> figure, and always
> > >> build the plots from these shadow objects.  This gives us the
> > >> advantage of being able to shelve the shadow objects and 
> rebuild the
> > >> figures later.
> > >
> > > this is rather interesting !
> > > any code to point to ?
> >
> > Hi Sebastien,
> >
> > I'll see what I can extract from the code tomorrow at work.  It's
> > pretty modular so I should be able to point to something.
> 
> any news about this ?
> 
> cheers,
> sebastien.
> -- 
> ###################################
> # Dr. Sebastien Binet
> # Lawrence Berkeley National Lab.
> # 1 Cyclotron Road
> # Berkeley, CA 94720
> ###################################
> 
> 

Attachment: plot_manager_data_classes.py
Description: plot_manager_data_classes.py

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to