On Tue, Apr 26, 2011 at 3:02 PM, Eric Firing <efiring@hawaii.edu> wrote:
On 04/26/2011 09:36 AM, butterw@gmail.com wrote:
> I believe this feature, which has been requested a number of times, but
> is still missing from matplotlib is genuinely useful for interactive
> plotting. Moreover, I've heard matlab has it...
>
> Here's a potential solution to cover my simple plotting needs. The goal
> is not to support all the weird and wonderful matplotlib features, if
> you need those you probably work only from script anyway. My approach is
> based on figureoptions.py in matplotlib.backends.qt4_editor (or the more
> recent version in spyder):
>
> 1) Save figure file:
> . get xy data for each plot object
> . get object styles (color of plots, linestyle, etc.)
> . save to auto-generated python script
>
> Later...
>
> 2) Open figure file:
> The script will open a new figure, recreate all objects and then apply
> styles to each object.
>  >> You have full control over the figure and its contents again for editing
>
> Using this approach backwards compatibility should not be a issue (as
> demonstrated by figureoptions). On the other hand not all matplotlib
> objects/options will be supported.
>
> Any comments or suggestions ?

Implementing anything like this will immediately lead to a stream of
complaints that it doesn't support "all the weird and wonderful
matplotlib features".

The vector backends are actually doing something like this, but saving
in their respective graphics languages instead of in python.  Presumably
some sort of "matplotlib_script" backend could be written, using the pdf
or svg backend as a template.

Better practice is to use something like the ipython logging facility to
save one's interactive commands, and then manually to edit that down to
a script that creates the desired figure.  That way one retains full
control, reproducibility, and documentation of what went into a figure.

Eric


Not meaning to resurrect a dead thread, but I would like to point out that Matlab's functionality appears to have been implemented by saving figure components in a .mat file (but called them .fig instead).  I have not investigated this any further, but I would wonder just how far-fetched it would be to be able to pickle the artist objects into our own sort of .fig files that we could load up on our own?

Just food for thought...

Ben Root