matplotlib figure serialization - matplotlib-users - Matplotlib
matplotlib figure serialization Community matplotlib-users Rich_Krauter March 24, 2010, 3:30pm 1 Hello, I am a relatively new user of matplotlib; thank you to the matplotlib team for this excellent package. I have a question about serializing matplotlib figures. I have searched for serialization options for matplotlib figures but have not found much information. I am interested to hear about serialization use cases and the approaches others use in these cases.
Here is the reason I am asking: My use case for serialization is that I want to build a CouchDB database of matplotlib figures. The database could be accessed from a web application (in my case I want to build a django app to create, edit and manage figures) or desktop gui, or whatever. For storage of the figures in CouchDB, I am working on JSON representations of matplotlib figures. The JSON could be run through simple python functions to regenerate the matplotlib figures.
I have very simple working examples, but to more completely test out this approach I would attempt to recreate the plots in the matplotlib gallery using JSON representations and a small set of (hopefully) very simple python functions which would process the JSON markup. Before I get too far, I wanted to see what others have done for similar use cases, make sure I am not missing existing approaches, etc. I am getting ahead of myself now, but if there is broader interest in this approach, and no other better solutions exist, I would set up a project on Google Code or some other site to work on this.
Your feedback is very much appreciated. Thanks! Rich Michael_Droettboom1 March 24, 2010, 5:15pm 2 What is the advantage of JSON (is this specific case) over Python source code? matplotlib is designed around it and it's more flexible. Unless you're planning on automatically manipulating the JSON, I don't see why you wouldn't just use Python source. Mike Rich Krauter wrote: ··· Hello, I am a relatively new user of matplotlib; thank you to the matplotlib team for this excellent package.
I have a question about serializing matplotlib figures. I have searched for serialization options for matplotlib figures but have not found much information. I am interested to hear about serialization use cases and the approaches others use in these cases. Here is the reason I am asking: My use case for serialization is that I want to build a CouchDB database of matplotlib figures. The database could be accessed from a web application (in my case I want to build a django app to create, edit and manage figures) or desktop gui, or whatever.
For storage of the figures in CouchDB, I am working on JSON representations of matplotlib figures. The JSON could be run through simple python functions to regenerate the matplotlib figures. I have very simple working examples, but to more completely test out this approach I would attempt to recreate the plots in the matplotlib gallery using JSON representations and a small set of (hopefully) very simple python functions which would process the JSON markup.
Before I get too far, I wanted to see what others have done for similar use cases, make sure I am not missing existing approaches, etc. I am getting ahead of myself now, but if there is broader interest in this approach, and no other better solutions exist, I would set up a project on Google Code or some other site to work on this. Your feedback is very much appreciated. Thanks! Rich ------------------------------------------------------------------------ ------------------------------------------------------------------------------ Download Intel& #174 ; Parallel Studio Eval Try the new software tools for yourself.
Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev ------------------------------------------------------------------------ _______________________________________________ Matplotlib-users mailing list [email protected] matplotlib-users List Signup and Options -- Michael Droettboom Science Software Branch Operations and Engineering Division Space Telescope Science Institute Operated by AURA for NASA _Chris_Barker March 24, 2010, 5:37pm 3 Michael Droettboom wrote: What is the advantage of JSON (is this specific case) over Python source code? matplotlib is designed around it and it's more flexible.
Unless you're planning on automatically manipulating the JSON, I don't see why you wouldn't just use Python source. Indeed. There have been a few threads about this topic, and I think the consensus is that the way to auto-generate figures is with python. I don't think that there is any technical reason that one couldn't create a serialized version of an MPL figure in XML, or JSON, (or, for that matter, a python data structure), but it would be a fair bit of effort to write the code, and I don't think you'd get any real advantage over just using scripts -- you need a python script to create a figure in the first place, why not serialize that? -Chris ··· -- Christopher Barker, Ph.D.
Oceanographer Emergency Response Division NOAA/NOS/OR&R (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception [email protected] ... Rich_Krauter March 24, 2010, 6:52pm 4 Rich Krauter wrote: Hello, I am a relatively new user of matplotlib; thank you to the matplotlib team for this excellent package. I have a question about serializing matplotlib figures. I have searched for serialization options for matplotlib figures but have not found much information.
I am interested to hear about serialization use cases and the approaches others use in these cases. Here is the reason I am asking: My use case for serialization is that I want to build a CouchDB database of matplotlib figures. The database could be accessed from a web application (in my case I want to build a django app to create, edit and manage figures) or desktop gui, or whatever. For storage of the figures in CouchDB, I am working on JSON representations of matplotlib figures.
The JSON could be run through simple python functions to regenerate the matplotlib figures. I have very simple working examples, but to more completely test out this approach I would attempt to recreate the plots in the matplotlib gallery using JSON representations and a small set of (hopefully) very simple python functions which would process the JSON markup. Before I get too far, I wanted to see what others have done for similar use cases, make sure I am not missing existing approaches, etc.
I am getting ahead of myself now, but if there is broader interest in this approach, and no other better solutions exist, I would set up a project on Google Code or some other site to work on this. What is the advantage of JSON (is this specific case) over Python source code? matplotlib is designed around it and it's more flexible. Unless you're planning on automatically manipulating the JSON, I don't see why you wouldn't just use Python source.
Mike Mike, I don't know that there is much of a benefit to JSON outside of my use case or similar use cases. I want to manipulate the JSON representation of a figure within a javascript-based web interface to provide dynamic plotting through a web page. I also want to be able to store and query JSON representations using CouchDB. I am probably not exactly clear on what you mean by "using python source" to represent a figure.
Is there a standard agreed upon way to do this? I do have python source code representations of figures. i.e. I have dict representations of matplotlib figures. The dicts have a "required" internal structure. I feed the dict to a function which regenerates the figure graphic from that structure. If I want to update the plot, I just change the contents of the dict data structure representing the plot, not the source code that is used to generate the figure.
If I instead had a JSON object representation of a figur
The rest of this page is on the live site.