Hi. I am finding that matplotlib does not allow me to decouple certain
actions from the GUI as much as I'd like.
For example, I have not been able to do any of the following tasks. Some of
these tasks are certainly artificial, but they all succinctly illustrate
some of the problems I've been running into when doing more realistic stuff.
1. *without bringing up any GUI window*, generate a list of all the
filetypes available to a specific matplotlib installation for saving
graphics (e.g. .ps, .svg, .pdf, .png, etc.);
2. switch back-and-forth between sending graphics objects for display to the
GUI and sending them for saving to any of the available filetypes (as
defined in (1));
3. (by far the most important one) *without activating any backend*, create
a graphics object (I explain what I mean by this below).
To clarify what I mean by (3), the best I can do is to give an example from
Mathematica. In Mathematica, a Graphics object does not need to be
displayed. It can be defined as a collection of Graphics primitives,
without ever displaying it in the GUI. One such definition would be
something like
In[1]:= g = Graphics[Line[{{1., 2.}, {2., 3.}, {3., 5.}}]];
This is what I mean in (3) by creating a graphics object without displaying
it (in the GUI). From a design perspective, this makes a lot of sense,
since a Graphics object, as an idea, is entirely independent of whatever
mean one chooses to display it. I want my code to reflect this conceptual
independence.
Regarding task (2), to make it more concrete, consider this (also
artificial) exercise: write a script that iterates over all filetypes
identified in (1); at each iteration, generate some random graphic (e.g. of
the sort shown here
http://matplotlib.sourceforge.net/examples/api/patch_collection.html),
display it on the GUI, and save it as a file of the type corresponding to
the iteration.
I would very much appreciate some hints/guidance on how to solve them.
As I noted, by far the most important of these tasks is (3). From looking
into the matplotlib source code, it looks to me impossible to do this with
standard matplotlib functions. But I am very much of a noob with mpl, so I
still hope there's a way.
In the worst case scenario (i.e. (3) can't be done directly using standard
mpl functions), then the only solution that I can think of would involve
implementing a separate layer of abstract graphics objects, distinct from
mpl's. This layer would then delegate to mpl the task of displaying the
graphics objects whenever the user requests it. Any suggestions on how best
to do this would be much appreciated. In particular, I'd like to know what
would be the right place to insert this new graphics object layer into the
matplotlib objects stack. I think it would be best to make this connection
at a level deeper than the axes object, but I'm not quite sure how to do
this.
Thanks in advance!
kj
------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1, ECMAScript5, and DOM L2 & L3.
Spend less time writing and rewriting code and more time creating great
experiences on the web. Be a part of the beta today
http://p.sf.net/sfu/msIE9-sfdev2dev
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel