Fernando Perez wrote: > Hi Michael, > > On Mon, Sep 14, 2009 at 6:57 AM, Michael Droettboom <md...@stsci.edu> wrote: > >> I'm not sure it's that bad. It's certainly possible to do all these things >> with a single directive, since providing a path or providing source code is >> mutually exclusive. The thing one can't do is provide inline source *and* a >> caption. I applied your patch, renaming the directive back to "plot" and >> ran it over the matplotlib docs, and it doesn't seem to break anything. >> > > Well, if you're OK with the api-by-inputs approach (name+text = > caption, text only=code), then I have no qualms using it. It felt a > bit hackish so I was perhaps overly cautious, but I'd much rather: > > - have this in upstream mpl than in my own projects > - have a single directive to remember > > So many thanks for integrating it! > Yeah, I have the same "not quite right" feeling about it. What about putting the caption in an "option" such as:
.. plot:: foo.py :caption: This is my caption I don't know if the caption can have newlines in this mode, though. I will have to experiment. >> Of course, we can also provide two directives, "plot" and "figplot" based on >> essentially the same source code. I'm kind of neutral on the matter. >> > > I'm pretty neutral too, though perhaps it might be worth thinking > about this a little more, to get a really good long-term solution. > > 2. An extended version of today's support for files, that can handle > entry points: > > .. plot:: script.py func1 > > Caption for figure 1 > > .. plot:: script.py func2 > > Caption for figure 2 > > This would *import* script only once, and then for each figure it > would call the given function (argumentless, to keep things simple for > now). Basically each call would be the equivalent of > > import script; script.funcN() # N=1,2 > > This would make it easy to compute expensive data in script once, and > then render multiple plots out of it without re-executing the script > in full each time. > > Or is this already possible with today's plot()? > It's not possible now. The tricky part of this is that currently we don't keep the module around after it's done plotting. This is actually very much on purpose since keeping all that data around for all of the example plots in the matplotlib documentation would quickly consume a lot of memory. Perhaps when used in this mode (with a function argument) we could. Alas, again that's api-by-inputs :) Mike -- Michael Droettboom Science Software Branch Operations and Engineering Division Space Telescope Science Institute Operated by AURA for NASA ------------------------------------------------------------------------------ Come build with us! The BlackBerry® Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9-12, 2009. Register now! http://p.sf.net/sfu/devconf _______________________________________________ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel