Persistent Matplotlib Figures

Christopher Barker <Chris.Barker@...236...> writes:

Joey Wilson wrote:

I would like to be able to save the figures from
matplotlib in an editable form, without flattening down to an image
file.

I think to do this right, you'd need to completely re-design MPL to be
based on a more declarative structure: [...] but it seems that MPL is
built to be used from a scripting interface instead: a series of
commands that builds the figure.

I don't think that is the real problem. How matplotlib works is that the
plotting commands build up a data structure consisting of various
objects pointing to each other, and when you call show or savefig, the
data structure is traversed and the appropriate backend functions are
called. In principle it should not be very difficult to serialize this
data structure, but since extension objects are involved, some work
might be needed to get it right.

What I think is the really difficult part is keeping the serialized
format somehow usable across different versions of matplotlib. When
anything changes in the various classes, the developers would need to
decide how the change is reflected in the on-disk format, how files
corresponding to the old class should be read in using the new class,
etc. Perhaps something like Google's protocol buffers could be used to
make this easier, but it would still be an burden on all subsequent
development.

···

--
Jouni K. Seppänen
http://www.iki.fi/jks

Jouni K. Seppänen wrote:

Christopher Barker <Chris.Barker@...236...> writes:

Joey Wilson wrote:

I would like to be able to save the figures from matplotlib in an editable form, without flattening down to an image file.

I think to do this right, you'd need to completely re-design MPL to be based on a more declarative structure: [...] but it seems that MPL is built to be used from a scripting interface instead: a series of commands that builds the figure.

I don't think that is the real problem. How matplotlib works is that the
plotting commands build up a data structure consisting of various
objects pointing to each other, and when you call show or savefig, the
data structure is traversed and the appropriate backend functions are
called. In principle it should not be very difficult to serialize this
data structure, but since extension objects are involved, some work
might be needed to get it right.

What I think is the really difficult part is keeping the serialized
format somehow usable across different versions of matplotlib. When
anything changes in the various classes, the developers would need to
decide how the change is reflected in the on-disk format, how files
corresponding to the old class should be read in using the new class,
etc. Perhaps something like Google's protocol buffers could be used to
make this easier, but it would still be an burden on all subsequent
development.

Exactly. I *strongly* oppose any move in this direction. It would be enabling bad workflow strategy on the part of users, providing no benefit that cannot be achieved better with a good workflow strategy, and adding complexity. We have enough of that already. We need to think about how to clean up mpl and make it easier to maintain and improve, not clutter it with ever more complexity.

Eric

+1 That pretty much sums up how I feel.

Ryan

···

On Sat, Dec 19, 2009 at 2:03 PM, Eric Firing <efiring@...229...> wrote:

Exactly. I *strongly* oppose any move in this direction. It would be
enabling bad workflow strategy on the part of users, providing no
benefit that cannot be achieved better with a good workflow strategy,
and adding complexity. We have enough of that already. We need to
think about how to clean up mpl and make it easier to maintain and
improve, not clutter it with ever more complexity.

--
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma