Re: [matplotlib-devel] preparing for 0.99.1
On Thu, Sep 10, 2009 at 8:08 PM, John Hunter wrote: > We've had a significant number of bug-fixes in the release branch, so > this weekend I'm going to try and put out a release candidate for > 0.99.1, and perhaps this will be the last release of this branch but > time will tell. I'll build the tarball and OSX binaries for the > release candidate, and perhaps Christoph can build the win32 binaries > for testing. If all goes well we can proceed with the release later > next week. I've uploaded the 0.99.1 release candidate to the drop.io site, with a tarball and OSX eggs and dmg files for python 2.5 and 2.6. Christoph, if you could now make the win32 binaries (not sure what to do abut the numpy/64bit problem but we can at least build the others) I'll send out a call for testing on the user list. http://drop.io/xortel1 Andrew, I also edited the make.osx file I use on the buildbot and added a new target called "binaries" to ease the process of making the nightly builds and to also incorporate all the fixes we discovered at the scipy script which may have caused linking problems in the old binaries I was building. I may need to install additional stuff on sage buildbot (in particular bdist_mpkg) to make this work, but we are a step closer to the nightly builds. Thanks, JDH -- Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july ___ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
[matplotlib-devel] Question on sphinxext.plot_directive...
Hi folks, if one were to say, think of writing something like a book (or a paper) using sphinx and plots generated from python scripts, the plot directive would be extremely useful. But as best as I can tell, it generates at the end of the day 'image' directives, where as for including figures in latex-produced PDF with captions and labels one can later refer to, the plain sphinx 'figure' directive appears to be more appropriate. As we can read here: http://docutils.sourceforge.net/docs/ref/rst/directives.html#images Their signatures are: Image Directive Type: "image" Doctree Element:image Directive Arguments:One, required (image URI). Directive Options: Possible. Directive Content: None. Figure Directive Type: "figure" Doctree Elements: figure, image, caption, legend Directive Arguments:One, required (image URI). Directive Options: Possible. Directive Content: Interpreted as the figure caption and an optional legend. A key difference is that image takes no content, while figure accepts content and uses it for the figure caption. Would it be possible/sensible to switch the plot directive to be a superset of 'figure' instead of 'image'? Before I dive into the code too far, I figured I'd ask the experts. Thanks! f -- Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july ___ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
Re: [matplotlib-devel] Question on sphinxext.plot_directive...
On Sat, Sep 12, 2009 at 8:29 PM, Fernando Perez wrote: > Before I dive into the code too far, I figured I'd ask the experts. Too late for that, common sense has never been my forte. Here's a diff against current trunk to play with this idea. WARNING: Please note that this is NOT meant to be applied for mpl yet!!! I've actually modified the plot directive and renamed it to 'figplot', so we can experiment a little to better understand things. The point is that this now lets us write reST of this type: .. figplot:: code/make_figure_brainx.py :width: 3.6 in **Example from fMRI data:** In the graph presented, the nodes represent the areas of the brain described in Figure 1. Nodes are labeled accordingly and etc... The text block is then passed as a caption to latex. I renamed it because there's a bit of a conflict with the current 'plot' directive, which allows a filename *or* a content block, but in that case the content block is meant to be the source code, as illustrated in sampledoc: http://matplotlib.sourceforge.net/sampledoc/extensions.html#inserting-matplotlib-plots Since I'm not sure if we can find a clean solution to: - path to script: goes into arg list - inlined (multiline) code: goes into content block - inlined (possibly multiline) caption: goes into content block I put this version so we can start experimenting. This does what Ariel and I need, but I hope over time we can figure out a good long-term solution. Speaking of sphinx for books, as I've mentioned before to John, the last big problem is being able to cross-reference arbitrary text elements like you can in latex, be they chapters or sections or whatever, and get a number or something that's meaningful in print. I looked around, and apparently it's on the main docutils todo list: http://docutils.sourceforge.net/docs/dev/todo.html#object-numbering-and-object-references I hope we don't have to be the ones fixing that one... Cheers, f Index: plot_directive.py === --- plot_directive.py (revision 7753) +++ plot_directive.py (working copy) @@ -46,7 +46,7 @@ import matplotlib.image as image from matplotlib import _pylab_helpers -import only_directives +from matplotlib.sphinxext import only_directives if hasattr(os.path, 'relpath'): relpath = os.path.relpath @@ -100,12 +100,16 @@ [%(links)s] - .. image:: %(prefix)s%(tmpdir)s/%(outname)s.png + .. figure:: %(prefix)s%(tmpdir)s/%(outname)s.png %(options)s +%(caption)s + .. latexonly:: - .. image:: %(prefix)s%(tmpdir)s/%(outname)s.pdf + .. figure:: %(prefix)s%(tmpdir)s/%(outname)s.pdf %(options)s + +%(caption)s """ exception_template = """ @@ -228,10 +232,15 @@ return len(fig_managers) -def plot_directive(name, arguments, options, content, lineno, +def figplot_directive(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine): """ Handle the plot directive. + +Modified from the original matplotlib plot directive. + +This one does NOT allow source code, only filenames, but it produces a +'figure' instead of an 'image', along with an optional caption. """ formats = setup.config.plot_formats if type(formats) == str: @@ -243,16 +252,26 @@ basedir, fname = os.path.split(reference) basename, ext = os.path.splitext(fname) basedir = relpath(basedir, setup.app.builder.srcdir) -if len(content): -raise ValueError("plot directive may not specify both a filename and inline content") -content = None +# If there is content, it will be passed as a caption. + +# Indent to match expansion below. XXX - The number of spaces matches +# that of the 'options' expansion further down (plus 3, which is the +# indent in the templates above). This should be moved to common code +# to prevent them from diverging accidentally. +caption = '\n'.join(' %s' % line.strip() for line in content) +plot_code = None else: basedir = "inline" -content = '\n'.join(content) +plot_code = '\n'.join(content) +caption = '' # Since we don't have a filename, use a hash based on the content -reference = basename = md5(content).hexdigest()[-10:] +reference = basename = md5(plot_code).hexdigest()[-10:] fname = None +# One way or another, we've transformed the content, so set it to null +# further on. +content = None + # Get the directory of the rst file, and determine the relative # path from the resulting html file to the plot_directive links # (linkdir). This relative path is used for html links *only*, @@ -289,12 +308,13 @@ cbook.mkdirs(destdir) # Generate the figures, and return the number of them -num_figs = makefig(reference, content, tmpdir) +num_figs = makefig(
Re: [matplotlib-devel] Question on sphinxext.plot_directive...
On Sat, Sep 12, 2009 at 11:12 PM, Fernando Perez wrote: > Here's a diff against current trunk to play with this idea. Updated patch that handles correctly more than one option (I think the bug was even in the original, not sure). Cheers, f Index: plot_directive.py === --- plot_directive.py (revision 7753) +++ plot_directive.py (working copy) @@ -46,7 +46,7 @@ import matplotlib.image as image from matplotlib import _pylab_helpers -import only_directives +from matplotlib.sphinxext import only_directives if hasattr(os.path, 'relpath'): relpath = os.path.relpath @@ -100,12 +100,16 @@ [%(links)s] - .. image:: %(prefix)s%(tmpdir)s/%(outname)s.png - %(options)s + .. figure:: %(prefix)s%(tmpdir)s/%(outname)s.png +%(options)s +%(caption)s + .. latexonly:: - .. image:: %(prefix)s%(tmpdir)s/%(outname)s.pdf - %(options)s + .. figure:: %(prefix)s%(tmpdir)s/%(outname)s.pdf +%(options)s + +%(caption)s """ exception_template = """ @@ -228,10 +232,15 @@ return len(fig_managers) -def plot_directive(name, arguments, options, content, lineno, +def figplot_directive(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine): """ Handle the plot directive. + +Modified from the original matplotlib plot directive. + +This one does NOT allow source code, only filenames, but it produces a +'figure' instead of an 'image', along with an optional caption. """ formats = setup.config.plot_formats if type(formats) == str: @@ -243,16 +252,25 @@ basedir, fname = os.path.split(reference) basename, ext = os.path.splitext(fname) basedir = relpath(basedir, setup.app.builder.srcdir) -if len(content): -raise ValueError("plot directive may not specify both a filename and inline content") -content = None +# If there is content, it will be passed as a caption. + +# Indent to match expansion below. XXX - The number of spaces matches +# that of the 'options' expansion further down. This should be moved +# to common code to prevent them from diverging accidentally. +caption = '\n'.join(' %s' % line.strip() for line in content) +plot_code = None else: basedir = "inline" -content = '\n'.join(content) +plot_code = '\n'.join(content) +caption = '' # Since we don't have a filename, use a hash based on the content -reference = basename = md5(content).hexdigest()[-10:] +reference = basename = md5(plot_code).hexdigest()[-10:] fname = None +# One way or another, we've transformed the content, so set it to null +# further on. +content = None + # Get the directory of the rst file, and determine the relative # path from the resulting html file to the plot_directive links # (linkdir). This relative path is used for html links *only*, @@ -289,18 +307,19 @@ cbook.mkdirs(destdir) # Generate the figures, and return the number of them -num_figs = makefig(reference, content, tmpdir) +num_figs = makefig(reference, plot_code, tmpdir) if options.has_key('include-source'): -if content is None: -content = open(reference, 'r').read() -lines = ['::', ''] + ['%s'%row.rstrip() for row in content.split('\n')] +if plot_code is None: +plot_code = open(reference, 'r').read() +lines = ['::', ''] + ['%s'%row.rstrip() + for row in plot_code.split('\n')] del options['include-source'] else: lines = [] if num_figs > 0: -options = [' :%s: %s' % (key, val) for key, val in +options = [' :%s: %s' % (key, val) for key, val in options.items()] options = "\n".join(options) if fname is not None: @@ -339,7 +358,7 @@ setup.config = app.config setup.confdir = app.confdir -app.add_directive('plot', plot_directive, True, (0, 1, 0), **options) +app.add_directive('figplot', figplot_directive, True, (0, 1, 0), **options) app.add_config_value( 'plot_formats', ['png', 'hires.png', 'pdf'], -- Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july___ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel