From: <md...@us...> - 2008-05-14 13:54:38
|
Revision: 5137 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5137&view=rev Author: mdboom Date: 2008-05-14 06:52:22 -0700 (Wed, 14 May 2008) Log Message: ----------- Merged revisions 5135-5136 via svnmerge from https://matplotlib.svn.sf.net/svnroot/matplotlib/branches/v0_91_maint ........ r5136 | mdboom | 2008-05-14 08:59:46 -0400 (Wed, 14 May 2008) | 2 lines Fix font embedding on Windows. ........ Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/lib/matplotlib/cbook.py Property Changed: ---------------- trunk/matplotlib/ Property changes on: trunk/matplotlib ___________________________________________________________________ Name: svnmerge-integrated - /branches/v0_91_maint:1-5134 + /branches/v0_91_maint:1-5136 Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2008-05-14 12:59:46 UTC (rev 5136) +++ trunk/matplotlib/CHANGELOG 2008-05-14 13:52:22 UTC (rev 5137) @@ -1,3 +1,5 @@ +2008-05-14 Don't use stat on Windows (fixes font embedding problem) - MGD + 2008-05-09 Fix /singlequote (') in Postscript backend - MGD 2008-05-08 Fix kerning in SVG when embedding character outlines - MGD Modified: trunk/matplotlib/lib/matplotlib/cbook.py =================================================================== --- trunk/matplotlib/lib/matplotlib/cbook.py 2008-05-14 12:59:46 UTC (rev 5136) +++ trunk/matplotlib/lib/matplotlib/cbook.py 2008-05-14 13:52:22 UTC (rev 5137) @@ -413,8 +413,11 @@ result = self._cache.get(path) if result is None: realpath = os.path.realpath(path) - stat = os.stat(realpath) - stat_key = (stat.st_ino, stat.st_dev) + if sys.platform == 'win32': + stat_key = realpath + else: + stat = os.stat(realpath) + stat_key = (stat.st_ino, stat.st_dev) result = realpath, stat_key self._cache[path] = result return result This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2008-05-14 16:40:44
|
Revision: 5138 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5138&view=rev Author: mdboom Date: 2008-05-14 09:39:28 -0700 (Wed, 14 May 2008) Log Message: ----------- Fix various bugs submitted by Matthias Michler: - Parts of text.py were not updated for the new transforms - Import/namespace errors in custom_projection_example.py, poly_editor.py - Fix legend_scatter.py Modified Paths: -------------- trunk/matplotlib/examples/custom_projection_example.py trunk/matplotlib/examples/legend_scatter.py trunk/matplotlib/examples/poly_editor.py trunk/matplotlib/lib/matplotlib/legend.py trunk/matplotlib/lib/matplotlib/text.py Modified: trunk/matplotlib/examples/custom_projection_example.py =================================================================== --- trunk/matplotlib/examples/custom_projection_example.py 2008-05-14 13:52:22 UTC (rev 5137) +++ trunk/matplotlib/examples/custom_projection_example.py 2008-05-14 16:39:28 UTC (rev 5138) @@ -7,6 +7,8 @@ BboxTransformTo, IdentityTransform, Transform, TransformWrapper from matplotlib.projections import register_projection +import numpy as npy + # This example projection class is rather long, but it is designed to # illustrate many features, not all of which will be used every time. # It is also common to factor out a lot of these methods into common Modified: trunk/matplotlib/examples/legend_scatter.py =================================================================== --- trunk/matplotlib/examples/legend_scatter.py 2008-05-14 13:52:22 UTC (rev 5137) +++ trunk/matplotlib/examples/legend_scatter.py 2008-05-14 16:39:28 UTC (rev 5138) @@ -3,7 +3,7 @@ N=1000 -props = dict( alpha=0.5, faceted=False ) +props = dict( alpha=0.5, edgecolors='none' ) handles = [] colours = ['red', 'green', 'blue', 'magenta', 'cyan', 'yellow'] Modified: trunk/matplotlib/examples/poly_editor.py =================================================================== --- trunk/matplotlib/examples/poly_editor.py 2008-05-14 13:52:22 UTC (rev 5137) +++ trunk/matplotlib/examples/poly_editor.py 2008-05-14 16:39:28 UTC (rev 5138) @@ -5,7 +5,7 @@ """ from matplotlib.artist import Artist from matplotlib.patches import Polygon, CirclePolygon -from numpy import sqrt, nonzero, equal, asarray, dot, amin +from numpy import sqrt, nonzero, equal, array, asarray, dot, amin, cos, sin from matplotlib.mlab import dist_point_to_segment @@ -69,7 +69,7 @@ 'get the index of the vertex under point if within epsilon tolerance' # display coords - xy = npy.asarray(self.poly.xy) + xy = asarray(self.poly.xy) xyt = self.poly.get_transform().transform(xy) xt, yt = xyt[:, 0], xyt[:, 1] d = sqrt((xt-event.x)**2 + (yt-event.y)**2) @@ -114,7 +114,7 @@ s1 = xys[i+1] d = dist_point_to_segment(p, s0, s1) if d<=self.epsilon: - self.poly.xy = npy.array( + self.poly.xy = array( list(self.poly.xy[:i]) + [(event.xdata, event.ydata)] + list(self.poly.xy[i:])) @@ -152,8 +152,8 @@ theta = arange(0, 2*pi, 0.1) r = 1.5 -xs = r*npy.cos(theta) -ys = r*npy.sin(theta) +xs = r*cos(theta) +ys = r*sin(theta) poly = Polygon(zip(xs, ys,), animated=True) Modified: trunk/matplotlib/lib/matplotlib/legend.py =================================================================== --- trunk/matplotlib/lib/matplotlib/legend.py 2008-05-14 13:52:22 UTC (rev 5137) +++ trunk/matplotlib/lib/matplotlib/legend.py 2008-05-14 16:39:28 UTC (rev 5138) @@ -288,7 +288,7 @@ width = self.handlelen, height=HEIGHT/2, ) p.set_facecolor(handle._facecolors[0]) - if handle._edgecolors != 'None': + if handle._edgecolors != 'none' and len(handle._edgecolors): p.set_edgecolor(handle._edgecolors[0]) self._set_artist_props(p) p.set_clip_box(None) Modified: trunk/matplotlib/lib/matplotlib/text.py =================================================================== --- trunk/matplotlib/lib/matplotlib/text.py 2008-05-14 13:52:22 UTC (rev 5137) +++ trunk/matplotlib/lib/matplotlib/text.py 2008-05-14 16:39:28 UTC (rev 5138) @@ -1083,7 +1083,7 @@ dx, dy = self._get_xy(dx, dy, self.xycoords) # convert the offset - dpi = self.figure.dpi.get() + dpi = self.figure.get_dpi() x *= dpi/72. y *= dpi/72. @@ -1095,7 +1095,7 @@ elif s=='polar': theta, r = x, y x = r*np.cos(theta) - y = r*np.cosmsin(theta) + y = r*np.sin(theta) trans = self.axes.transData return trans.transform_point((x,y)) elif s=='figure points': This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2008-05-15 13:03:54
|
Revision: 5140 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5140&view=rev Author: mdboom Date: 2008-05-15 06:03:49 -0700 (Thu, 15 May 2008) Log Message: ----------- Fix Tk backend segfault. Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/src/_tkagg.cpp Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2008-05-14 17:28:26 UTC (rev 5139) +++ trunk/matplotlib/CHANGELOG 2008-05-15 13:03:49 UTC (rev 5140) @@ -1,3 +1,5 @@ +2008-05-15 Fix Tk backend segfault on some machines - MGD + 2008-05-14 Don't use stat on Windows (fixes font embedding problem) - MGD 2008-05-09 Fix /singlequote (') in Postscript backend - MGD Modified: trunk/matplotlib/src/_tkagg.cpp =================================================================== --- trunk/matplotlib/src/_tkagg.cpp 2008-05-14 17:28:26 UTC (rev 5139) +++ trunk/matplotlib/src/_tkagg.cpp 2008-05-15 13:03:49 UTC (rev 5140) @@ -11,6 +11,7 @@ #include <Python.h> #include <stdlib.h> +#include <sstream> #include "agg_basics.h" #include "_backend_agg.h" @@ -50,6 +51,7 @@ agg::int8u *destbuffer; double l,b,r,t; int destx, desty, destwidth, destheight, deststride; + unsigned long tmp_ptr; long mode; long nval; @@ -71,7 +73,10 @@ return TCL_ERROR; } /* get array (or object that can be converted to array) pointer */ - aggo = (PyObject*)atol(argv[2]); + std::stringstream agg_ptr_ss; + agg_ptr_ss.str(argv[2]); + agg_ptr_ss >> tmp_ptr; + aggo = (PyObject*)tmp_ptr; RendererAgg *aggRenderer = (RendererAgg *)aggo; int srcheight = (int)aggRenderer->get_height(); @@ -85,7 +90,10 @@ } /* check for bbox/blitting */ - bboxo = (PyObject*)atol(argv[4]); + std::stringstream bbox_ptr_ss; + bbox_ptr_ss.str(argv[4]); + bbox_ptr_ss >> tmp_ptr; + bboxo = (PyObject*)tmp_ptr; if (py_convert_bbox(bboxo, l, b, r, t)) { has_bbox = true; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mme...@us...> - 2008-05-16 14:53:01
|
Revision: 5147 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5147&view=rev Author: mmetz_bn Date: 2008-05-16 07:52:15 -0700 (Fri, 16 May 2008) Log Message: ----------- added cumulative histograms Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/lib/matplotlib/axes.py Added Paths: ----------- trunk/matplotlib/examples/histogram_demo_cumulative.py Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2008-05-16 13:41:25 UTC (rev 5146) +++ trunk/matplotlib/CHANGELOG 2008-05-16 14:52:15 UTC (rev 5147) @@ -1,3 +1,7 @@ +2008-05-16 Added 'cumulative' keyword arg to hist to plot cumulative + histograms. For normed hists, this is normalized to one + assuming equally spaced bins - MM + 2008-05-15 Fix Tk backend segfault on some machines - MGD 2008-05-14 Don't use stat on Windows (fixes font embedding problem) - MGD Added: trunk/matplotlib/examples/histogram_demo_cumulative.py =================================================================== --- trunk/matplotlib/examples/histogram_demo_cumulative.py (rev 0) +++ trunk/matplotlib/examples/histogram_demo_cumulative.py 2008-05-16 14:52:15 UTC (rev 5147) @@ -0,0 +1,33 @@ +#!/usr/bin/env python +from pylab import * + +mu, sigma = 100, 25 +x = mu + sigma*randn(10000) + +# the histogram of the data +n, bins, patches = hist(x, 50, normed=1, histtype='step', cumulative=True) +setp(patches, 'facecolor', 'g', 'alpha', 0.75) + +# add a 'best fit' line +y = normpdf( bins, mu, sigma).cumsum() +y /= y[-1] +l = plot(bins, y, 'k--', linewidth=1.5) + +# overlay the first histogram with a second one +# were the data has a smaller standard deviation +mu, sigma = 100, 10 +x = mu + sigma*randn(10000) + +n, bins, patches = hist(x, bins=bins, normed=1, histtype='step', cumulative=True) +setp(patches, 'facecolor', 'r', 'alpha', 0.25) + +# add a 'best fit' line +y = normpdf( bins, mu, sigma).cumsum() +y /= y[-1] +l = plot(bins, y, 'k--', linewidth=1.5) + +grid(True) +ylim(0, 1.1) + +#savefig('histogram_demo',dpi=72) +show() \ No newline at end of file Modified: trunk/matplotlib/lib/matplotlib/axes.py =================================================================== --- trunk/matplotlib/lib/matplotlib/axes.py 2008-05-16 13:41:25 UTC (rev 5146) +++ trunk/matplotlib/lib/matplotlib/axes.py 2008-05-16 14:52:15 UTC (rev 5147) @@ -5416,9 +5416,9 @@ #### Data analysis - def hist(self, x, bins=10, normed=False, bottom=None, histtype='bar', - align='edge', orientation='vertical', width=None, - log=False, **kwargs): + def hist(self, x, bins=10, normed=False, cumulative=False, + bottom=None, histtype='bar', align='edge', + orientation='vertical', width=None, log=False, **kwargs): """ HIST(x, bins=10, normed=False, bottom=None, histtype='bar', align='edge', orientation='vertical', width=None, @@ -5439,6 +5439,12 @@ pdf, bins, patches = ax.hist(...) print np.trapz(pdf, bins) + If cumulative is True then histogram is computed where each bin + gives the counts in that bin plus all bins for smaller values. + The last bins gives the total number of datapoints. If normed is + also True then the histogram is normalized such that the last bin + equals one (assuming equally spaced bins). + histtype = 'bar' | 'step'. The type of histogram to draw. 'bar' is a traditional bar-type histogram, 'step' generates a lineplot. @@ -5461,6 +5467,12 @@ if not self._hold: self.cla() n, bins = np.histogram(x, bins, range=None, normed=bool(normed), new=True) + + if cumulative: + n = n.cumsum() + if normed: + # normalize to 1 + n *= (bins[1]-bins[0]) if histtype == 'bar': if width is None: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mme...@us...> - 2008-05-16 17:48:10
|
Revision: 5149 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5149&view=rev Author: mmetz_bn Date: 2008-05-16 10:47:51 -0700 (Fri, 16 May 2008) Log Message: ----------- Added elinewidth keyword arg to errorbar bases on patch by Christopher Brown Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/lib/matplotlib/axes.py Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2008-05-16 17:06:53 UTC (rev 5148) +++ trunk/matplotlib/CHANGELOG 2008-05-16 17:47:51 UTC (rev 5149) @@ -1,6 +1,8 @@ +2008-05-16 Added 'elinewidth' keyword arg to errorbar, based on patch + by Christopher Brown - MM + 2008-05-16 Added 'cumulative' keyword arg to hist to plot cumulative - histograms. For normed hists, this is normalized to one - assuming equally spaced bins - MM + histograms. For normed hists, this is normalized to one - MM 2008-05-15 Fix Tk backend segfault on some machines - MGD Modified: trunk/matplotlib/lib/matplotlib/axes.py =================================================================== --- trunk/matplotlib/lib/matplotlib/axes.py 2008-05-16 17:06:53 UTC (rev 5148) +++ trunk/matplotlib/lib/matplotlib/axes.py 2008-05-16 17:47:51 UTC (rev 5149) @@ -3752,13 +3752,13 @@ def errorbar(self, x, y, yerr=None, xerr=None, - fmt='-', ecolor=None, capsize=3, + fmt='-', ecolor=None, elinewidth=None, capsize=3, barsabove=False, lolims=False, uplims=False, xlolims=False, xuplims=False, **kwargs): """ ERRORBAR(x, y, yerr=None, xerr=None, - fmt='b-', ecolor=None, capsize=3, barsabove=False, - lolims=False, uplims=False, + fmt='b-', ecolor=None, elinewidth=None, capsize=3, + barsabove=False, lolims=False, uplims=False, xlolims=False, xuplims=False) Plot x versus y with error deltas in yerr and xerr. @@ -3783,6 +3783,9 @@ ecolor is a matplotlib color arg which gives the color the errorbar lines; if None, use the marker color. + elinewidth is the linewidth of the errorbar lines; + if None, use the linewidth. + capsize is the size of the error bar caps in points barsabove, if True, will plot the errorbars above the plot symbols @@ -3842,10 +3845,13 @@ caplines = [] lines_kw = {'label':'_nolegend_'} - if 'linewidth' in kwargs: - lines_kw['linewidth']=kwargs['linewidth'] - if 'lw' in kwargs: - lines_kw['lw']=kwargs['lw'] + if elinewidth: + lines_kw['linewidth'] = elinewidth + else: + if 'linewidth' in kwargs: + lines_kw['linewidth']=kwargs['linewidth'] + if 'lw' in kwargs: + lines_kw['lw']=kwargs['lw'] if 'transform' in kwargs: lines_kw['transform'] = kwargs['transform'] @@ -5432,8 +5438,7 @@ If normed is true, the first element of the return tuple will be the counts normalized to form a probability density, ie, n/(len(x)*dbin). In a probability density, the integral of - the histogram should be one (we assume equally spaced bins); - you can verify that with + the histogram should be one; you can verify that with # trapezoidal integration of the probability density function pdf, bins, patches = ax.hist(...) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jd...@us...> - 2008-05-16 21:58:47
|
Revision: 5163 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5163&view=rev Author: jdh2358 Date: 2008-05-16 14:58:39 -0700 (Fri, 16 May 2008) Log Message: ----------- purged some dead code dirs; these can live in the maint branch Removed Paths: ------------- trunk/matplotlib/makeswig.py trunk/matplotlib/mpl1/ trunk/matplotlib/sandbox/units/ trunk/matplotlib/swig/ Deleted: trunk/matplotlib/makeswig.py =================================================================== --- trunk/matplotlib/makeswig.py 2008-05-16 21:01:39 UTC (rev 5162) +++ trunk/matplotlib/makeswig.py 2008-05-16 21:58:39 UTC (rev 5163) @@ -1,23 +0,0 @@ -""" -requires swig cvs as of 2005-02-24 -""" -import os, sys -wrap = ( - 'agg', - ) -#SWIG = 'swig' -SWIG = '/home/titan/johnh/dev/bin/swig' -AGGINCLUDE = 'agg23/include' - -swigit = '%(SWIG)s -python -c++ -outdir lib/matplotlib -o src/%(SWIGFILE)s.cxx -I%(AGGINCLUDE)s swig/%(SWIGFILE)s.i ' - - -os.system('%(SWIG)s -python -external-runtime src/swig_runtime.h'%locals()) -for SWIGFILE in wrap: - command = swigit%locals() - print 'swigging %s'%SWIGFILE - print command - os.system(command) - - - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jd...@us...> - 2008-05-16 22:26:17
|
Revision: 5164 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5164&view=rev Author: jdh2358 Date: 2008-05-16 15:26:15 -0700 (Fri, 16 May 2008) Log Message: ----------- removed pre py2.4 compatability code and some other dead code Modified Paths: -------------- trunk/matplotlib/API_CHANGES trunk/matplotlib/CHANGELOG trunk/matplotlib/lib/matplotlib/_cm.py trunk/matplotlib/lib/matplotlib/axis.py trunk/matplotlib/lib/matplotlib/backends/backend_agg.py trunk/matplotlib/lib/matplotlib/backends/backend_cairo.py trunk/matplotlib/lib/matplotlib/backends/backend_emf.py trunk/matplotlib/lib/matplotlib/backends/backend_fltkagg.py trunk/matplotlib/lib/matplotlib/backends/backend_gdk.py trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py trunk/matplotlib/lib/matplotlib/backends/backend_ps.py trunk/matplotlib/lib/matplotlib/backends/backend_qt.py trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py trunk/matplotlib/lib/matplotlib/backends/backend_qtagg.py trunk/matplotlib/lib/matplotlib/backends/backend_template.py trunk/matplotlib/lib/matplotlib/backends/backend_tkagg.py trunk/matplotlib/lib/matplotlib/cbook.py trunk/matplotlib/lib/matplotlib/figure.py trunk/matplotlib/lib/matplotlib/pylab.py trunk/matplotlib/lib/matplotlib/text.py Removed Paths: ------------- trunk/matplotlib/lib/subprocess/ Modified: trunk/matplotlib/API_CHANGES =================================================================== --- trunk/matplotlib/API_CHANGES 2008-05-16 21:58:39 UTC (rev 5163) +++ trunk/matplotlib/API_CHANGES 2008-05-16 22:26:15 UTC (rev 5164) @@ -1,3 +1,6 @@ + matplotlib now requires python2.4, so matplotlib.cbook will no + loner provide set, enumerate, reversed or izip compatability functions + In numpy 1.0 bins are specified by the left edges only. The axes method "hist" now uses future numpy 1.3 semantic for histograms. Providing binedges, the last value gives the upper-right edge now, Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2008-05-16 21:58:39 UTC (rev 5163) +++ trunk/matplotlib/CHANGELOG 2008-05-16 22:26:15 UTC (rev 5164) @@ -1,5 +1,11 @@ -2008-05-16 Reorganized examples dir +2008-05-16 removed some unneeded code w/ the python 2.4 requirement. + cbook no longer provides compatibility for reversed, + enumerate, set or izip. removed lib/subprocess, mpl1, + sandbox/units, and the swig code. This stuff should remain + on the maintenance branch for archival purposes. JDH +2008-05-16 Reorganized examples dir - JDH + 2008-05-16 Added 'elinewidth' keyword arg to errorbar, based on patch by Christopher Brown - MM Modified: trunk/matplotlib/lib/matplotlib/_cm.py =================================================================== --- trunk/matplotlib/lib/matplotlib/_cm.py 2008-05-16 21:58:39 UTC (rev 5163) +++ trunk/matplotlib/lib/matplotlib/_cm.py 2008-05-16 22:26:15 UTC (rev 5164) @@ -11,7 +11,6 @@ import matplotlib as mpl import matplotlib.colors as colors -from matplotlib.cbook import reversed LUTSIZE = mpl.rcParams['image.lut'] _binary_data = { Modified: trunk/matplotlib/lib/matplotlib/axis.py =================================================================== --- trunk/matplotlib/lib/matplotlib/axis.py 2008-05-16 21:58:39 UTC (rev 5163) +++ trunk/matplotlib/lib/matplotlib/axis.py 2008-05-16 22:26:15 UTC (rev 5164) @@ -4,7 +4,7 @@ from __future__ import division from artist import Artist, setp -from cbook import enumerate, silent_list, popall, CallbackRegistry +from cbook import silent_list, popall, CallbackRegistry from lines import Line2D, TICKLEFT, TICKRIGHT, TICKUP, TICKDOWN from matplotlib import rcParams from patches import bbox_artist Modified: trunk/matplotlib/lib/matplotlib/backends/backend_agg.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_agg.py 2008-05-16 21:58:39 UTC (rev 5163) +++ trunk/matplotlib/lib/matplotlib/backends/backend_agg.py 2008-05-16 22:26:15 UTC (rev 5164) @@ -31,8 +31,7 @@ from matplotlib._pylab_helpers import Gcf from matplotlib.backend_bases import RendererBase,\ GraphicsContextBase, FigureManagerBase, FigureCanvasBase -from matplotlib.cbook import enumerate, is_string_like, exception_to_str, \ - maxdict +from matplotlib.cbook import is_string_like, exception_to_str, maxdict from matplotlib.figure import Figure from matplotlib.font_manager import findfont from matplotlib.ft2font import FT2Font, LOAD_FORCE_AUTOHINT Modified: trunk/matplotlib/lib/matplotlib/backends/backend_cairo.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_cairo.py 2008-05-16 21:58:39 UTC (rev 5163) +++ trunk/matplotlib/lib/matplotlib/backends/backend_cairo.py 2008-05-16 22:26:15 UTC (rev 5164) @@ -36,7 +36,7 @@ from matplotlib.backend_bases import RendererBase, GraphicsContextBase,\ FigureManagerBase, FigureCanvasBase -from matplotlib.cbook import enumerate, izip, is_string_like +from matplotlib.cbook import is_string_like from matplotlib.figure import Figure from matplotlib.mathtext import MathTextParser from matplotlib.path import Path Modified: trunk/matplotlib/lib/matplotlib/backends/backend_emf.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_emf.py 2008-05-16 21:58:39 UTC (rev 5163) +++ trunk/matplotlib/lib/matplotlib/backends/backend_emf.py 2008-05-16 22:26:15 UTC (rev 5164) @@ -17,7 +17,6 @@ from matplotlib._pylab_helpers import Gcf from matplotlib.backend_bases import RendererBase, GraphicsContextBase,\ FigureManagerBase, FigureCanvasBase -from matplotlib.cbook import enumerate from matplotlib.figure import Figure from matplotlib.transforms import Bbox Modified: trunk/matplotlib/lib/matplotlib/backends/backend_fltkagg.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_fltkagg.py 2008-05-16 21:58:39 UTC (rev 5163) +++ trunk/matplotlib/lib/matplotlib/backends/backend_fltkagg.py 2008-05-16 22:26:15 UTC (rev 5164) @@ -20,7 +20,7 @@ import matplotlib from matplotlib import rcParams, verbose -from matplotlib.cbook import is_string_like, enumerate +from matplotlib.cbook import is_string_like from matplotlib.backend_bases import \ RendererBase, GraphicsContextBase, FigureManagerBase, FigureCanvasBase,\ NavigationToolbar2, cursors Modified: trunk/matplotlib/lib/matplotlib/backends/backend_gdk.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_gdk.py 2008-05-16 21:58:39 UTC (rev 5163) +++ trunk/matplotlib/lib/matplotlib/backends/backend_gdk.py 2008-05-16 22:26:15 UTC (rev 5164) @@ -22,7 +22,7 @@ from matplotlib._pylab_helpers import Gcf from matplotlib.backend_bases import RendererBase, GraphicsContextBase, \ FigureManagerBase, FigureCanvasBase -from matplotlib.cbook import is_string_like, enumerate +from matplotlib.cbook import is_string_like from matplotlib.figure import Figure from matplotlib.mathtext import MathTextParser from matplotlib.transforms import Affine2D Modified: trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py 2008-05-16 21:58:39 UTC (rev 5163) +++ trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py 2008-05-16 22:26:15 UTC (rev 5164) @@ -19,7 +19,7 @@ from matplotlib.backend_bases import RendererBase, GraphicsContextBase, \ FigureManagerBase, FigureCanvasBase, NavigationToolbar2, cursors from matplotlib.backends.backend_gdk import RendererGDK, FigureCanvasGDK -from matplotlib.cbook import is_string_like, is_writable_file_like, enumerate +from matplotlib.cbook import is_string_like, is_writable_file_like from matplotlib.colors import colorConverter from matplotlib.figure import Figure from matplotlib.widgets import SubplotTool Modified: trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py 2008-05-16 21:58:39 UTC (rev 5163) +++ trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py 2008-05-16 22:26:15 UTC (rev 5164) @@ -25,7 +25,7 @@ from matplotlib.backend_bases import RendererBase, GraphicsContextBase,\ FigureManagerBase, FigureCanvasBase from matplotlib.backends.backend_mixed import MixedModeRenderer -from matplotlib.cbook import Bunch, enumerate, is_string_like, reverse_dict, \ +from matplotlib.cbook import Bunch, is_string_like, reverse_dict, \ get_realpath_and_stat, is_writable_file_like, maxdict from matplotlib.figure import Figure from matplotlib.font_manager import findfont, is_opentype_cff_font Modified: trunk/matplotlib/lib/matplotlib/backends/backend_ps.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_ps.py 2008-05-16 21:58:39 UTC (rev 5163) +++ trunk/matplotlib/lib/matplotlib/backends/backend_ps.py 2008-05-16 22:26:15 UTC (rev 5164) @@ -14,7 +14,7 @@ from matplotlib.backend_bases import RendererBase, GraphicsContextBase,\ FigureManagerBase, FigureCanvasBase -from matplotlib.cbook import is_string_like, izip, get_realpath_and_stat, \ +from matplotlib.cbook import is_string_like, get_realpath_and_stat, \ is_writable_file_like, maxdict from matplotlib.figure import Figure Modified: trunk/matplotlib/lib/matplotlib/backends/backend_qt.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_qt.py 2008-05-16 21:58:39 UTC (rev 5163) +++ trunk/matplotlib/lib/matplotlib/backends/backend_qt.py 2008-05-16 22:26:15 UTC (rev 5164) @@ -5,7 +5,7 @@ import matplotlib from matplotlib import verbose -from matplotlib.cbook import is_string_like, enumerate, onetrue +from matplotlib.cbook import is_string_like, onetrue from matplotlib.backend_bases import RendererBase, GraphicsContextBase, \ FigureManagerBase, FigureCanvasBase, NavigationToolbar2, cursors from matplotlib._pylab_helpers import Gcf Modified: trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py 2008-05-16 21:58:39 UTC (rev 5163) +++ trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py 2008-05-16 22:26:15 UTC (rev 5164) @@ -5,7 +5,7 @@ import matplotlib from matplotlib import verbose -from matplotlib.cbook import is_string_like, enumerate, onetrue +from matplotlib.cbook import is_string_like, onetrue from matplotlib.backend_bases import RendererBase, GraphicsContextBase, \ FigureManagerBase, FigureCanvasBase, NavigationToolbar2, cursors from matplotlib._pylab_helpers import Gcf Modified: trunk/matplotlib/lib/matplotlib/backends/backend_qtagg.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_qtagg.py 2008-05-16 21:58:39 UTC (rev 5163) +++ trunk/matplotlib/lib/matplotlib/backends/backend_qtagg.py 2008-05-16 22:26:15 UTC (rev 5164) @@ -6,7 +6,6 @@ import os, sys import matplotlib from matplotlib import verbose -from matplotlib.cbook import enumerate from matplotlib.figure import Figure from backend_agg import FigureCanvasAgg Modified: trunk/matplotlib/lib/matplotlib/backends/backend_template.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_template.py 2008-05-16 21:58:39 UTC (rev 5163) +++ trunk/matplotlib/lib/matplotlib/backends/backend_template.py 2008-05-16 22:26:15 UTC (rev 5164) @@ -49,7 +49,6 @@ from matplotlib._pylab_helpers import Gcf from matplotlib.backend_bases import RendererBase, GraphicsContextBase,\ FigureManagerBase, FigureCanvasBase -from matplotlib.cbook import enumerate from matplotlib.figure import Figure from matplotlib.transforms import Bbox Modified: trunk/matplotlib/lib/matplotlib/backends/backend_tkagg.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_tkagg.py 2008-05-16 21:58:39 UTC (rev 5163) +++ trunk/matplotlib/lib/matplotlib/backends/backend_tkagg.py 2008-05-16 22:26:15 UTC (rev 5164) @@ -11,7 +11,7 @@ import os.path import matplotlib -from matplotlib.cbook import is_string_like, enumerate +from matplotlib.cbook import is_string_like from matplotlib.backend_bases import RendererBase, GraphicsContextBase, \ FigureManagerBase, FigureCanvasBase, NavigationToolbar2, cursors Modified: trunk/matplotlib/lib/matplotlib/cbook.py =================================================================== --- trunk/matplotlib/lib/matplotlib/cbook.py 2008-05-16 21:58:39 UTC (rev 5163) +++ trunk/matplotlib/lib/matplotlib/cbook.py 2008-05-16 22:26:15 UTC (rev 5164) @@ -7,11 +7,6 @@ import time, datetime import numpy as np -try: - set = set -except NameError: - from sets import Set as set - major, minor1, minor2, s, tmp = sys.version_info @@ -462,47 +457,7 @@ return self.data[i % len(self.data)] -# use enumerate builtin if available, else use python version -try: - import __builtin__ - enumerate = __builtin__.enumerate -except: - def enumerate(seq): - """Python equivalent to the enumerate builtin function - enumerate() is new in Python 2.3 - """ - for i in range(len(seq)): - yield i, seq[i] - -# use reversed builtin if available, else use python version -try: - import __builtin__ - reversed = __builtin__.reversed -except: - def reversed(seq): - """Python equivalent to the enumerate builtin function - enumerate() is new in Python 2.3 - """ - for i in range(len(seq)-1,-1,-1): - yield seq[i] - - -# use itertools.izip if available, else use python version -try: - import itertools - izip = itertools.izip -except: - def izip(*iterables): - """Python equivalent to itertools.izip - itertools module - new in Python 2.3 - """ - iterables = map(iter, iterables) - while iterables: - result = [i.next() for i in iterables] - yield tuple(result) - - def get_split_ind(seq, N): """seq is a list of words. Return the index into seq such that len(' '.join(seq[:ind])<=N Modified: trunk/matplotlib/lib/matplotlib/figure.py =================================================================== --- trunk/matplotlib/lib/matplotlib/figure.py 2008-05-16 21:58:39 UTC (rev 5163) +++ trunk/matplotlib/lib/matplotlib/figure.py 2008-05-16 22:26:15 UTC (rev 5164) @@ -7,7 +7,7 @@ import artist from artist import Artist from axes import Axes, SubplotBase, subplot_class_factory -from cbook import flatten, allequal, Stack, iterable, dedent, set +from cbook import flatten, allequal, Stack, iterable, dedent import _image import colorbar as cbar from image import FigureImage Modified: trunk/matplotlib/lib/matplotlib/pylab.py =================================================================== --- trunk/matplotlib/lib/matplotlib/pylab.py 2008-05-16 21:58:39 UTC (rev 5163) +++ trunk/matplotlib/lib/matplotlib/pylab.py 2008-05-16 22:26:15 UTC (rev 5164) @@ -195,7 +195,7 @@ import sys, warnings from cbook import flatten, is_string_like, exception_to_str, popd, \ - silent_list, iterable, enumerate, dedent + silent_list, iterable, dedent import numpy as np from numpy import ma Modified: trunk/matplotlib/lib/matplotlib/text.py =================================================================== --- trunk/matplotlib/lib/matplotlib/text.py 2008-05-16 21:58:39 UTC (rev 5163) +++ trunk/matplotlib/lib/matplotlib/text.py 2008-05-16 22:26:15 UTC (rev 5164) @@ -10,7 +10,7 @@ from matplotlib import rcParams import artist from artist import Artist -from cbook import enumerate, is_string_like, maxdict +from cbook import is_string_like, maxdict from font_manager import FontProperties from patches import bbox_artist, YAArrow from transforms import Affine2D, Bbox This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jd...@us...> - 2008-05-16 22:47:05
|
Revision: 5165 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5165&view=rev Author: jdh2358 Date: 2008-05-16 15:47:00 -0700 (Fri, 16 May 2008) Log Message: ----------- backend driver fix Modified Paths: -------------- trunk/matplotlib/Makefile trunk/matplotlib/examples/pylab/agg_buffer_to_array.py trunk/matplotlib/examples/pylab/annotation_demo.py trunk/matplotlib/examples/pylab/clippedline.py trunk/matplotlib/examples/pylab/colours.py trunk/matplotlib/examples/pylab/contourf_log.py trunk/matplotlib/examples/pylab/custom_projection_example.py trunk/matplotlib/examples/pylab/custom_scale_example.py trunk/matplotlib/examples/pylab/data_browser.py trunk/matplotlib/examples/pylab/fill_between.py trunk/matplotlib/examples/pylab/geo_demo.py trunk/matplotlib/examples/pylab/lineprops_dialog_gtk.py trunk/matplotlib/examples/pylab/mathtext_demo.py trunk/matplotlib/examples/pylab/pcolor_nonuniform.py trunk/matplotlib/examples/pylab/polar_bar.py trunk/matplotlib/examples/pylab/polar_demo.py trunk/matplotlib/examples/pylab/polar_legend.py trunk/matplotlib/examples/pylab/quadmesh_demo.py trunk/matplotlib/examples/pylab/step_demo.py trunk/matplotlib/examples/pylab/strip_chart_demo.py trunk/matplotlib/examples/pylab/symlog_demo.py trunk/matplotlib/examples/pylab/webapp_demo.py trunk/matplotlib/examples/tests/backend_driver.py Modified: trunk/matplotlib/Makefile =================================================================== --- trunk/matplotlib/Makefile 2008-05-16 22:26:15 UTC (rev 5164) +++ trunk/matplotlib/Makefile 2008-05-16 22:47:00 UTC (rev 5165) @@ -15,7 +15,6 @@ rm -f *.png *.ps *.eps *.svg *.jpg *.pdf find . -name "_tmp*.py" | xargs rm -f;\ find . \( -name "*~" -o -name "*.pyc" \) | xargs rm -f;\ - find examples \( -name "*.svg" C-o -name "*.png" -o -name "*.pdf" -o -name "*.ps" -o -name "*.eps" -o -name "*.tar" -o -name "*.gz" -o -name "*.log" -o -name "*.aux" -o -name "*.tex" \) | xargs rm -f find unit \( -name "*.png" -o -name "*.ps" -o -name "*.pdf" -o -name "*.eps" \) | xargs rm -f find . \( -name "#*" -o -name ".#*" -o -name ".*~" -o -name "*~" \) | xargs rm -f Modified: trunk/matplotlib/examples/pylab/agg_buffer_to_array.py =================================================================== --- trunk/matplotlib/examples/pylab/agg_buffer_to_array.py 2008-05-16 22:26:15 UTC (rev 5164) +++ trunk/matplotlib/examples/pylab/agg_buffer_to_array.py 2008-05-16 22:47:00 UTC (rev 5165) @@ -1,7 +1,7 @@ import matplotlib matplotlib.use('Agg') from pylab import figure, show -import numpy as npy +import numpy as np # make an agg figure fig = figure() @@ -13,7 +13,7 @@ # grab rhe pixel buffer and dumpy it into a numpy array buf = fig.canvas.buffer_rgba(0,0) l, b, w, h = fig.bbox.bounds -X = npy.fromstring(buf, npy.uint8) +X = np.fromstring(buf, np.uint8) X.shape = h,w,4 # now display the array X as an Axes in a new figure Modified: trunk/matplotlib/examples/pylab/annotation_demo.py =================================================================== --- trunk/matplotlib/examples/pylab/annotation_demo.py 2008-05-16 22:26:15 UTC (rev 5164) +++ trunk/matplotlib/examples/pylab/annotation_demo.py 2008-05-16 22:47:00 UTC (rev 5165) @@ -35,7 +35,7 @@ from matplotlib.pyplot import figure, show from matplotlib.patches import Ellipse -import numpy as npy +import numpy as np if 1: @@ -44,8 +44,8 @@ fig = figure() ax = fig.add_subplot(111, autoscale_on=False, xlim=(-1,5), ylim=(-3,5)) - t = npy.arange(0.0, 5.0, 0.01) - s = npy.cos(2*npy.pi*t) + t = np.arange(0.0, 5.0, 0.01) + s = np.cos(2*np.pi*t) line, = ax.plot(t, s, lw=3, color='purple') ax.annotate('axes center', xy=(.5, .5), xycoords='axes fraction', @@ -94,8 +94,8 @@ # respected fig = figure() ax = fig.add_subplot(111, polar=True) - r = npy.arange(0,1,0.001) - theta = 2*2*npy.pi*r + r = np.arange(0,1,0.001) + theta = 2*2*np.pi*r line, = ax.plot(theta, r, color='#ee8d18', lw=3) ind = 800 @@ -124,8 +124,8 @@ ax.add_artist(el) el.set_clip_box(ax.bbox) ax.annotate('the top', - xy=(npy.pi/2., 10.), # theta, radius - xytext=(npy.pi/3, 20.), # theta, radius + xy=(np.pi/2., 10.), # theta, radius + xytext=(np.pi/3, 20.), # theta, radius xycoords='polar', textcoords='polar', arrowprops=dict(facecolor='black', shrink=0.05), Modified: trunk/matplotlib/examples/pylab/clippedline.py =================================================================== --- trunk/matplotlib/examples/pylab/clippedline.py 2008-05-16 22:26:15 UTC (rev 5164) +++ trunk/matplotlib/examples/pylab/clippedline.py 2008-05-16 22:47:00 UTC (rev 5165) @@ -4,7 +4,7 @@ """ from matplotlib.lines import Line2D -import numpy as npy +import numpy as np from pylab import figure, show class ClippedLine(Line2D): @@ -19,13 +19,13 @@ def set_data(self, *args, **kwargs): Line2D.set_data(self, *args, **kwargs) - self.xorig = npy.array(self._x) - self.yorig = npy.array(self._y) + self.xorig = np.array(self._x) + self.yorig = np.array(self._y) def draw(self, renderer): xlim = self.ax.get_xlim() - ind0, ind1 = npy.searchsorted(self.xorig, xlim) + ind0, ind1 = np.searchsorted(self.xorig, xlim) self._x = self.xorig[ind0:ind1] self._y = self.yorig[ind0:ind1] N = len(self._x) @@ -43,8 +43,8 @@ fig = figure() ax = fig.add_subplot(111, autoscale_on=False) -t = npy.arange(0.0, 100.0, 0.01) -s = npy.sin(2*npy.pi*t) +t = np.arange(0.0, 100.0, 0.01) +s = np.sin(2*np.pi*t) line = ClippedLine(ax, t, s, color='g', ls='-', lw=2) ax.add_line(line) ax.set_xlim(10,30) Modified: trunk/matplotlib/examples/pylab/colours.py =================================================================== --- trunk/matplotlib/examples/pylab/colours.py 2008-05-16 22:26:15 UTC (rev 5164) +++ trunk/matplotlib/examples/pylab/colours.py 2008-05-16 22:47:00 UTC (rev 5165) @@ -2,12 +2,12 @@ """ Some simple functions to generate colours. """ -import numpy as npy +import numpy as np from matplotlib.colors import colorConverter def pastel(colour, weight=2.4): """ Convert colour into a nice pastel shade""" - rgb = npy.asarray(colorConverter.to_rgb(colour)) + rgb = np.asarray(colorConverter.to_rgb(colour)) # scale colour maxc = max(rgb) if maxc < 1.0 and maxc > 0: @@ -31,7 +31,7 @@ def get_colours(n): """ Return n pastel colours. """ - base = npy.asarray([[1,0,0], [0,1,0], [0,0,1]]) + base = np.asarray([[1,0,0], [0,1,0], [0,0,1]]) if n <= 3: return base[0:n] @@ -42,7 +42,7 @@ colours = [] for start in (0, 1): - for x in npy.linspace(0, 1, needed[start]+2): + for x in np.linspace(0, 1, needed[start]+2): colours.append((base[start] * (1.0 - x)) + (base[start+1] * x)) Modified: trunk/matplotlib/examples/pylab/contourf_log.py =================================================================== --- trunk/matplotlib/examples/pylab/contourf_log.py 2008-05-16 22:26:15 UTC (rev 5164) +++ trunk/matplotlib/examples/pylab/contourf_log.py 2008-05-16 22:47:00 UTC (rev 5165) @@ -3,16 +3,16 @@ ''' from matplotlib import pyplot as P -import numpy as npy +import numpy as np from numpy import ma from matplotlib import colors, ticker from matplotlib.mlab import bivariate_normal N = 100 -x = npy.linspace(-3.0, 3.0, N) -y = npy.linspace(-2.0, 2.0, N) +x = np.linspace(-3.0, 3.0, N) +y = np.linspace(-2.0, 2.0, N) -X, Y = npy.meshgrid(x, y) +X, Y = np.meshgrid(x, y) # A low hump with a spike coming out of the top right. # Needs to have z/colour axis on a log scale so we see both hump and spike. @@ -34,9 +34,9 @@ # Alternatively, you can manually set the levels # and the norm: -#lev_exp = npy.arange(npy.floor(npy.log10(z.min())-1), -# npy.ceil(npy.log10(z.max())+1)) -#levs = npy.power(10, lev_exp) +#lev_exp = np.arange(np.floor(np.log10(z.min())-1), +# np.ceil(np.log10(z.max())+1)) +#levs = np.power(10, lev_exp) #cs = P.contourf(X, Y, z, levs, norm=colors.LogNorm()) #The 'extend' kwarg does not work yet with a log scale. Modified: trunk/matplotlib/examples/pylab/custom_projection_example.py =================================================================== --- trunk/matplotlib/examples/pylab/custom_projection_example.py 2008-05-16 22:26:15 UTC (rev 5164) +++ trunk/matplotlib/examples/pylab/custom_projection_example.py 2008-05-16 22:47:00 UTC (rev 5165) @@ -7,7 +7,7 @@ BboxTransformTo, IdentityTransform, Transform, TransformWrapper from matplotlib.projections import register_projection -import numpy as npy +import numpy as np # This example projection class is rather long, but it is designed to # illustrate many features, not all of which will be used every time. @@ -60,8 +60,8 @@ # be changed by the user. This makes the math in the # transformation itself easier, and since this is a toy # example, the easier, the better. - Axes.set_xlim(self, -npy.pi, npy.pi) - Axes.set_ylim(self, -npy.pi / 2.0, npy.pi / 2.0) + Axes.set_xlim(self, -np.pi, np.pi) + Axes.set_ylim(self, -np.pi / 2.0, np.pi / 2.0) def cla(self): """ @@ -79,8 +79,8 @@ # self.grid(rcParams['axes.grid']) - Axes.set_xlim(self, -npy.pi, npy.pi) - Axes.set_ylim(self, -npy.pi / 2.0, npy.pi / 2.0) + Axes.set_xlim(self, -np.pi, np.pi) + Axes.set_ylim(self, -np.pi / 2.0, np.pi / 2.0) def _set_lim_and_transforms(self): """ @@ -117,8 +117,8 @@ # within the axes. The peculiar calculations of xscale and # yscale are specific to a Aitoff-Hammer projection, so don't # worry about them too much. - xscale = 2.0 * npy.sqrt(2.0) * npy.sin(0.5 * npy.pi) - yscale = npy.sqrt(2.0) * npy.sin(0.5 * npy.pi) + xscale = 2.0 * np.sqrt(2.0) * np.sin(0.5 * np.pi) + yscale = np.sqrt(2.0) * np.sin(0.5 * np.pi) self.transAffine = Affine2D() \ .scale(0.5 / xscale, 0.5 / yscale) \ .translate(0.5, 0.5) @@ -148,8 +148,8 @@ # pixels from the equator. self._xaxis_pretransform = \ Affine2D() \ - .scale(1.0, npy.pi) \ - .translate(0.0, -npy.pi) + .scale(1.0, np.pi) \ + .translate(0.0, -np.pi) self._xaxis_transform = \ self._xaxis_pretransform + \ self.transData @@ -168,7 +168,7 @@ # (1, ymax). The goal of these transforms is to go from that # space to display space. The tick labels will be offset 4 # pixels from the edge of the axes ellipse. - yaxis_stretch = Affine2D().scale(npy.pi * 2.0, 1.0).translate(-npy.pi, 0.0) + yaxis_stretch = Affine2D().scale(np.pi * 2.0, 1.0).translate(-np.pi, 0.0) yaxis_space = Affine2D().scale(1.0, 1.1) self._yaxis_transform = \ yaxis_stretch + \ @@ -265,8 +265,8 @@ # set_xlim and set_ylim to ignore any input. This also applies to # interactive panning and zooming in the GUI interfaces. def set_xlim(self, *args, **kwargs): - Axes.set_xlim(self, -npy.pi, npy.pi) - Axes.set_ylim(self, -npy.pi / 2.0, npy.pi / 2.0) + Axes.set_xlim(self, -np.pi, np.pi) + Axes.set_ylim(self, -np.pi / 2.0, np.pi / 2.0) set_ylim = set_xlim def format_coord(self, long, lat): @@ -276,8 +276,8 @@ In this case, we want them to be displayed in degrees N/S/E/W. """ - long = long * (180.0 / npy.pi) - lat = lat * (180.0 / npy.pi) + long = long * (180.0 / np.pi) + lat = lat * (180.0 / np.pi) if lat >= 0.0: ns = 'N' else: @@ -298,7 +298,7 @@ self._round_to = round_to def __call__(self, x, pos=None): - degrees = (x / npy.pi) * 180.0 + degrees = (x / np.pi) * 180.0 degrees = round(degrees / self._round_to) * self._round_to # \u00b0 : degree symbol return u"%d\u00b0" % degrees @@ -316,7 +316,7 @@ number = (360.0 / degrees) + 1 self.xaxis.set_major_locator( FixedLocator( - npy.linspace(-npy.pi, npy.pi, number, True)[1:-1])) + np.linspace(-np.pi, np.pi, number, True)[1:-1])) # Set the formatter to display the tick labels in degrees, # rather than radians. self.xaxis.set_major_formatter(self.DegreeFormatter(degrees)) @@ -334,7 +334,7 @@ number = (180.0 / degrees) + 1 self.yaxis.set_major_locator( FixedLocator( - npy.linspace(-npy.pi / 2.0, npy.pi / 2.0, number, True)[1:-1])) + np.linspace(-np.pi / 2.0, np.pi / 2.0, number, True)[1:-1])) # Set the formatter to display the tick labels in degrees, # rather than radians. self.yaxis.set_major_formatter(self.DegreeFormatter(degrees)) @@ -351,7 +351,7 @@ class -- it provides an interface to something that has no analogy in the base Axes class. """ - longitude_cap = degrees * (npy.pi / 180.0) + longitude_cap = degrees * (np.pi / 180.0) # Change the xaxis gridlines transform so that it draws from # -degrees to degrees, rather than -pi to pi. self._xaxis_pretransform \ @@ -412,13 +412,13 @@ # Pre-compute some values half_long = longitude / 2.0 - cos_latitude = npy.cos(latitude) - sqrt2 = npy.sqrt(2.0) + cos_latitude = np.cos(latitude) + sqrt2 = np.sqrt(2.0) - alpha = 1.0 + cos_latitude * npy.cos(half_long) - x = (2.0 * sqrt2) * (cos_latitude * npy.sin(half_long)) / alpha - y = (sqrt2 * npy.sin(latitude)) / alpha - return npy.concatenate((x, y), 1) + alpha = 1.0 + cos_latitude * np.cos(half_long) + x = (2.0 * sqrt2) * (cos_latitude * np.sin(half_long)) / alpha + y = (sqrt2 * np.sin(latitude)) / alpha + return np.concatenate((x, y), 1) # This is where things get interesting. With this projection, # straight lines in data space become curves in display space. @@ -451,10 +451,10 @@ quarter_x = 0.25 * x half_y = 0.5 * y - z = npy.sqrt(1.0 - quarter_x*quarter_x - half_y*half_y) - longitude = 2 * npy.arctan((z*x) / (2.0 * (2.0*z*z - 1.0))) - latitude = npy.arcsin(y*z) - return npy.concatenate((longitude, latitude), 1) + z = np.sqrt(1.0 - quarter_x*quarter_x - half_y*half_y) + longitude = 2 * np.arctan((z*x) / (2.0 * (2.0*z*z - 1.0))) + latitude = np.arcsin(y*z) + return np.concatenate((longitude, latitude), 1) transform.__doc__ = Transform.transform.__doc__ def inverted(self): Modified: trunk/matplotlib/examples/pylab/custom_scale_example.py =================================================================== --- trunk/matplotlib/examples/pylab/custom_scale_example.py 2008-05-16 22:26:15 UTC (rev 5164) +++ trunk/matplotlib/examples/pylab/custom_scale_example.py 2008-05-16 22:47:00 UTC (rev 5165) @@ -36,8 +36,8 @@ thresh: The degree above which to crop the data. """ mscale.ScaleBase.__init__(self) - thresh = kwargs.pop("thresh", (85 / 180.0) * npy.pi) - if thresh >= npy.pi / 2.0: + thresh = kwargs.pop("thresh", (85 / 180.0) * np.pi) + if thresh >= np.pi / 2.0: raise ValueError("thresh must be less than pi/2") self.thresh = thresh @@ -67,11 +67,11 @@ class DegreeFormatter(Formatter): def __call__(self, x, pos=None): # \u00b0 : degree symbol - return u"%d\u00b0" % ((x / npy.pi) * 180.0) + return u"%d\u00b0" % ((x / np.pi) * 180.0) - deg2rad = npy.pi / 180.0 + deg2rad = np.pi / 180.0 axis.set_major_locator(FixedLocator( - npy.arange(-90, 90, 10) * deg2rad)) + np.arange(-90, 90, 10) * deg2rad)) axis.set_major_formatter(DegreeFormatter()) axis.set_minor_formatter(DegreeFormatter()) @@ -118,9 +118,9 @@ """ masked = ma.masked_where((a < -self.thresh) | (a > self.thresh), a) if masked.mask.any(): - return ma.log(npy.abs(ma.tan(masked) + 1.0 / ma.cos(masked))) + return ma.log(np.abs(ma.tan(masked) + 1.0 / ma.cos(masked))) else: - return npy.log(npy.abs(npy.tan(a) + 1.0 / npy.cos(a))) + return np.log(np.abs(np.tan(a) + 1.0 / np.cos(a))) def inverted(self): """ @@ -139,7 +139,7 @@ self.thresh = thresh def transform(self, a): - return npy.arctan(npy.sinh(a)) + return np.arctan(np.sinh(a)) def inverted(self): return MercatorLatitudeScale.MercatorLatitudeTransform(self.thresh) @@ -149,10 +149,10 @@ mscale.register_scale(MercatorLatitudeScale) from pylab import * -import numpy as npy +import numpy as np t = arange(-180.0, 180.0, 0.1) -s = t / 360.0 * npy.pi +s = t / 360.0 * np.pi plot(t, s, '-', lw=2) gca().set_yscale('mercator') Modified: trunk/matplotlib/examples/pylab/data_browser.py =================================================================== --- trunk/matplotlib/examples/pylab/data_browser.py 2008-05-16 22:26:15 UTC (rev 5164) +++ trunk/matplotlib/examples/pylab/data_browser.py 2008-05-16 22:47:00 UTC (rev 5165) @@ -1,10 +1,10 @@ -import numpy as npy +import numpy as np from pylab import figure, show -X = npy.random.rand(100, 200) -xs = npy.mean(X, axis=1) -ys = npy.std(X, axis=1) +X = np.random.rand(100, 200) +xs = np.mean(X, axis=1) +ys = np.std(X, axis=1) fig = figure() ax = fig.add_subplot(211) @@ -25,18 +25,18 @@ transform=ax.transAxes, va='top') self.selected, = ax.plot([xs[0]], [ys[0]], 'o', ms=12, alpha=0.4, color='yellow', visible=False) - + def onpress(self, event): if self.lastind is None: return if event.key not in ('n', 'p'): return if event.key=='n': inc = 1 else: inc = -1 - + self.lastind += inc - self.lastind = npy.clip(self.lastind, 0, len(xs)-1) + self.lastind = np.clip(self.lastind, 0, len(xs)-1) self.update() - + def onpick(self, event): if event.artist!=line: return True @@ -49,7 +49,7 @@ y = event.mouseevent.ydata - distances = npy.hypot(x-xs[event.ind], y-ys[event.ind]) + distances = np.hypot(x-xs[event.ind], y-ys[event.ind]) indmin = distances.argmin() dataind = event.ind[indmin] Modified: trunk/matplotlib/examples/pylab/fill_between.py =================================================================== --- trunk/matplotlib/examples/pylab/fill_between.py 2008-05-16 22:26:15 UTC (rev 5164) +++ trunk/matplotlib/examples/pylab/fill_between.py 2008-05-16 22:47:00 UTC (rev 5165) @@ -1,11 +1,11 @@ #!/usr/bin/env python import matplotlib.mlab as mlab from pylab import figure, show -import numpy as npy +import numpy as np -x = npy.arange(0, 2, 0.01) -y1 = npy.sin(2*npy.pi*x) -y2 = npy.sin(4*npy.pi*x) + 2 +x = np.arange(0, 2, 0.01) +y1 = np.sin(2*np.pi*x) +y2 = np.sin(4*np.pi*x) + 2 fig = figure() ax = fig.add_subplot(311) Modified: trunk/matplotlib/examples/pylab/geo_demo.py =================================================================== --- trunk/matplotlib/examples/pylab/geo_demo.py 2008-05-16 22:26:15 UTC (rev 5164) +++ trunk/matplotlib/examples/pylab/geo_demo.py 2008-05-16 22:47:00 UTC (rev 5165) @@ -1,5 +1,5 @@ -import numpy as npy -npy.seterr("raise") +import numpy as np +np.seterr("raise") from pylab import * Modified: trunk/matplotlib/examples/pylab/lineprops_dialog_gtk.py =================================================================== --- trunk/matplotlib/examples/pylab/lineprops_dialog_gtk.py 2008-05-16 22:26:15 UTC (rev 5164) +++ trunk/matplotlib/examples/pylab/lineprops_dialog_gtk.py 2008-05-16 22:47:00 UTC (rev 5165) @@ -2,17 +2,17 @@ matplotlib.use('GTKAgg') from matplotlib.backends.backend_gtk import DialogLineprops -import numpy as npy +import numpy as np from pylab import figure, show def f(t): - s1 = npy.cos(2*npy.pi*t) - e1 = npy.exp(-t) - return npy.multiply(s1,e1) + s1 = np.cos(2*np.pi*t) + e1 = np.exp(-t) + return np.multiply(s1,e1) -t1 = npy.arange(0.0, 5.0, 0.1) -t2 = npy.arange(0.0, 5.0, 0.02) -t3 = npy.arange(0.0, 2.0, 0.01) +t1 = np.arange(0.0, 5.0, 0.1) +t2 = np.arange(0.0, 5.0, 0.02) +t3 = np.arange(0.0, 2.0, 0.01) fig = figure() ax = fig.add_subplot(111) Modified: trunk/matplotlib/examples/pylab/mathtext_demo.py =================================================================== --- trunk/matplotlib/examples/pylab/mathtext_demo.py 2008-05-16 22:26:15 UTC (rev 5164) +++ trunk/matplotlib/examples/pylab/mathtext_demo.py 2008-05-16 22:47:00 UTC (rev 5165) @@ -3,7 +3,7 @@ Use matplotlib's internal LaTex parser and layout engine. For true latex rendering, see the text.usetex option """ -import numpy as npy +import numpy as np from matplotlib.pyplot import figure, show fig = figure() @@ -11,7 +11,7 @@ ax = fig.add_subplot(111, axisbg='y') ax.plot([1,2,3], 'r') -x = npy.arange(0.0, 3.0, 0.1) +x = np.arange(0.0, 3.0, 0.1) ax.grid(True) ax.set_xlabel(r'$\Delta_i^j$', fontsize=20) Modified: trunk/matplotlib/examples/pylab/pcolor_nonuniform.py =================================================================== --- trunk/matplotlib/examples/pylab/pcolor_nonuniform.py 2008-05-16 22:26:15 UTC (rev 5164) +++ trunk/matplotlib/examples/pylab/pcolor_nonuniform.py 2008-05-16 22:47:00 UTC (rev 5165) @@ -1,11 +1,11 @@ from matplotlib.pyplot import figure, show -import numpy as npy +import numpy as np from matplotlib.image import NonUniformImage -x = npy.arange(-4, 4, 0.005) -y = npy.arange(-4, 4, 0.005) +x = np.arange(-4, 4, 0.005) +y = np.arange(-4, 4, 0.005) print 'Size %d points' % (len(x) * len(y)) -z = npy.sqrt(x[npy.newaxis,:]**2 + y[:,npy.newaxis]**2) +z = np.sqrt(x[np.newaxis,:]**2 + y[:,np.newaxis]**2) fig = figure() ax = fig.add_subplot(111) Modified: trunk/matplotlib/examples/pylab/polar_bar.py =================================================================== --- trunk/matplotlib/examples/pylab/polar_bar.py 2008-05-16 22:26:15 UTC (rev 5164) +++ trunk/matplotlib/examples/pylab/polar_bar.py 2008-05-16 22:47:00 UTC (rev 5165) @@ -1,6 +1,6 @@ #!/usr/bin/env python -import numpy as npy +import numpy as np import matplotlib.cm as cm from matplotlib.pyplot import figure, show, rc @@ -10,9 +10,9 @@ ax = fig.add_axes([0.1, 0.1, 0.8, 0.8], polar=True) N = 20 -theta = npy.arange(0.0, 2*npy.pi, 2*npy.pi/N) -radii = 10*npy.random.rand(N) -width = npy.pi/4*npy.random.rand(N) +theta = np.arange(0.0, 2*np.pi, 2*np.pi/N) +radii = 10*np.random.rand(N) +width = np.pi/4*np.random.rand(N) bars = ax.bar(theta, radii, width=width, bottom=0.0) for r,bar in zip(radii, bars): bar.set_facecolor( cm.jet(r/10.)) Modified: trunk/matplotlib/examples/pylab/polar_demo.py =================================================================== --- trunk/matplotlib/examples/pylab/polar_demo.py 2008-05-16 22:26:15 UTC (rev 5164) +++ trunk/matplotlib/examples/pylab/polar_demo.py 2008-05-16 22:47:00 UTC (rev 5165) @@ -39,7 +39,7 @@ # See the pylab rgrids and thetagrids functions for # information on how to customize the grid locations and labels -import numpy as npy +import numpy as np from matplotlib.pyplot import figure, show, rc, grid # radar green, solid grid lines @@ -51,8 +51,8 @@ fig = figure(figsize=(8,8)) ax = fig.add_axes([0.1, 0.1, 0.8, 0.8], polar=True, axisbg='#d5de9c') -r = npy.arange(0, 3.0, 0.01) -theta = 2*npy.pi*r +r = np.arange(0, 3.0, 0.01) +theta = 2*np.pi*r ax.plot(theta, r, color='#ee8d18', lw=3) ax.set_rmax(2.0) grid(True) Modified: trunk/matplotlib/examples/pylab/polar_legend.py =================================================================== --- trunk/matplotlib/examples/pylab/polar_legend.py 2008-05-16 22:26:15 UTC (rev 5164) +++ trunk/matplotlib/examples/pylab/polar_legend.py 2008-05-16 22:47:00 UTC (rev 5165) @@ -1,6 +1,6 @@ #!/usr/bin/env python -import numpy as npy +import numpy as np from matplotlib.pyplot import figure, show, rc # radar green, solid grid lines @@ -12,8 +12,8 @@ fig = figure(figsize=(8,8)) ax = fig.add_axes([0.1, 0.1, 0.8, 0.8], polar=True, axisbg='#d5de9c') -r = npy.arange(0, 3.0, 0.01) -theta = 2*npy.pi*r +r = np.arange(0, 3.0, 0.01) +theta = 2*np.pi*r ax.plot(theta, r, color='#ee8d18', lw=3, label='a line') ax.plot(0.5*theta, r, color='blue', ls='--', lw=3, label='another line') ax.legend() Modified: trunk/matplotlib/examples/pylab/quadmesh_demo.py =================================================================== --- trunk/matplotlib/examples/pylab/quadmesh_demo.py 2008-05-16 22:26:15 UTC (rev 5164) +++ trunk/matplotlib/examples/pylab/quadmesh_demo.py 2008-05-16 22:47:00 UTC (rev 5165) @@ -6,23 +6,23 @@ This demo illustrates a bug in quadmesh with masked data. """ -import numpy as npy +import numpy as np from matplotlib.pyplot import figure, show, savefig from matplotlib import cm, colors from numpy import ma n = 56 -x = npy.linspace(-1.5,1.5,n) -y = npy.linspace(-1.5,1.5,n*2) -X,Y = npy.meshgrid(x,y); -Qx = npy.cos(Y) - npy.cos(X) -Qz = npy.sin(Y) + npy.sin(X) +x = np.linspace(-1.5,1.5,n) +y = np.linspace(-1.5,1.5,n*2) +X,Y = np.meshgrid(x,y); +Qx = np.cos(Y) - np.cos(X) +Qz = np.sin(Y) + np.sin(X) Qx = (Qx + 1.1) -Z = npy.sqrt(X**2 + Y**2)/5; +Z = np.sqrt(X**2 + Y**2)/5; Z = (Z - Z.min()) / (Z.max() - Z.min()) # The color array can include masked values: -Zm = ma.masked_where(npy.fabs(Qz) < 0.5*npy.amax(Qz), Z) +Zm = ma.masked_where(np.fabs(Qz) < 0.5*np.amax(Qz), Z) fig = figure() Modified: trunk/matplotlib/examples/pylab/step_demo.py =================================================================== --- trunk/matplotlib/examples/pylab/step_demo.py 2008-05-16 22:26:15 UTC (rev 5164) +++ trunk/matplotlib/examples/pylab/step_demo.py 2008-05-16 22:47:00 UTC (rev 5165) @@ -1,9 +1,9 @@ -import numpy as npy +import numpy as np from numpy import ma from matplotlib.pyplot import step, legend, xlim, ylim, show -x = npy.arange(1, 7, 0.4) -y0 = npy.sin(x) +x = np.arange(1, 7, 0.4) +y0 = np.sin(x) y = y0.copy() + 2.5 step(x, y, label='pre (default)') Modified: trunk/matplotlib/examples/pylab/strip_chart_demo.py =================================================================== --- trunk/matplotlib/examples/pylab/strip_chart_demo.py 2008-05-16 22:26:15 UTC (rev 5164) +++ trunk/matplotlib/examples/pylab/strip_chart_demo.py 2008-05-16 22:47:00 UTC (rev 5165) @@ -12,7 +12,7 @@ import gobject, gtk import matplotlib matplotlib.use('GTKAgg') -import numpy as npy +import numpy as np from matplotlib.lines import Line2D @@ -36,9 +36,9 @@ def emitter(self, p=0.01): 'return a random value with probability p, else 0' - v = npy.random.rand(1) + v = np.random.rand(1) if v>p: return 0. - else: return npy.random.rand(1) + else: return np.random.rand(1) def update(self, *args): if self.background is None: return True Modified: trunk/matplotlib/examples/pylab/symlog_demo.py =================================================================== --- trunk/matplotlib/examples/pylab/symlog_demo.py 2008-05-16 22:26:15 UTC (rev 5164) +++ trunk/matplotlib/examples/pylab/symlog_demo.py 2008-05-16 22:47:00 UTC (rev 5165) @@ -19,7 +19,7 @@ subplot(313) -plot(x, npy.sin(x / 3.0)) +plot(x, np.sin(x / 3.0)) xscale('symlog') yscale('symlog') grid(True) Modified: trunk/matplotlib/examples/pylab/webapp_demo.py =================================================================== --- trunk/matplotlib/examples/pylab/webapp_demo.py 2008-05-16 22:26:15 UTC (rev 5164) +++ trunk/matplotlib/examples/pylab/webapp_demo.py 2008-05-16 22:47:00 UTC (rev 5165) @@ -21,7 +21,7 @@ from matplotlib.backends.backend_agg import FigureCanvasAgg from matplotlib.figure import Figure from matplotlib.cbook import iterable -import numpy as npy +import numpy as np def make_fig(): """ @@ -40,9 +40,9 @@ line, = ax.plot([1,2,3], 'ro--', markersize=12, markerfacecolor='g') # make a translucent scatter collection - x = npy.random.rand(100) - y = npy.random.rand(100) - area = npy.pi*(10 * npy.random.rand(100))**2 # 0 to 10 point radiuses + x = np.random.rand(100) + y = np.random.rand(100) + area = np.pi*(10 * np.random.rand(100))**2 # 0 to 10 point radiuses c = ax.scatter(x,y,area) c.set_alpha(0.5) Modified: trunk/matplotlib/examples/tests/backend_driver.py =================================================================== --- trunk/matplotlib/examples/tests/backend_driver.py 2008-05-16 22:26:15 UTC (rev 5164) +++ trunk/matplotlib/examples/tests/backend_driver.py 2008-05-16 22:47:00 UTC (rev 5165) @@ -181,7 +181,7 @@ line_lstrip = line.lstrip() if (line_lstrip.startswith('from __future__ import division') or line_lstrip.startswith('matplotlib.use') or - line_lstrip.find('savefig')>=0 or + line_lstrip.startswith('savefig') or line_lstrip.startswith('show')): continue tmpfile.write(line) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jd...@us...> - 2008-05-17 21:20:17
|
Revision: 5177 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5177&view=rev Author: jdh2358 Date: 2008-05-17 14:20:15 -0700 (Sat, 17 May 2008) Log Message: ----------- Merged revisions 5172 via svnmerge from https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/branches/v0_91_maint ........ r5172 | jdh2358 | 2008-05-17 16:06:05 -0500 (Sat, 17 May 2008) | 1 line added a doc string to the branch -- just experimenting with svn merge here ........ Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/cbook.py Property Changed: ---------------- trunk/matplotlib/ Property changes on: trunk/matplotlib ___________________________________________________________________ Name: svnmerge-integrated - /branches/v0_91_maint:1-4816 + /branches/v0_91_maint:1-4816,5172 Modified: trunk/matplotlib/lib/matplotlib/cbook.py =================================================================== --- trunk/matplotlib/lib/matplotlib/cbook.py 2008-05-17 21:19:10 UTC (rev 5176) +++ trunk/matplotlib/lib/matplotlib/cbook.py 2008-05-17 21:20:15 UTC (rev 5177) @@ -216,6 +216,7 @@ return is_string_like(obj) or not iterable(obj) def is_numlike(obj): + 'return true if obj looks like a number' try: obj+1 except TypeError: return False else: return True This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jd...@us...> - 2008-05-17 21:32:41
|
Revision: 5180 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5180&view=rev Author: jdh2358 Date: 2008-05-17 14:32:33 -0700 (Sat, 17 May 2008) Log Message: ----------- Merged revisions 5178-5179 via svnmerge from https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/branches/v0_91_maint ........ r5178 | jdh2358 | 2008-05-17 16:28:34 -0500 (Sat, 17 May 2008) | 1 line updated the coding guide to encourage svnmerge ........ r5179 | jdh2358 | 2008-05-17 16:30:23 -0500 (Sat, 17 May 2008) | 1 line a few more doc string fixes in cboo ........ Modified Paths: -------------- trunk/matplotlib/CODING_GUIDE trunk/matplotlib/lib/matplotlib/cbook.py Property Changed: ---------------- trunk/matplotlib/ Property changes on: trunk/matplotlib ___________________________________________________________________ Name: svnmerge-integrated - /branches/v0_91_maint:1-4816,5172 + /branches/v0_91_maint:1-4816,5172,5178-5179 Modified: trunk/matplotlib/CODING_GUIDE =================================================================== --- trunk/matplotlib/CODING_GUIDE 2008-05-17 21:30:23 UTC (rev 5179) +++ trunk/matplotlib/CODING_GUIDE 2008-05-17 21:32:33 UTC (rev 5180) @@ -41,10 +41,30 @@ MANIFEST.in. This file determines what goes into the src distribution of the mpl build. + * Keep the maintenance branch and trunk in sync here it makes sense. + If there is a bug on both that needs fixing, use svnmerge.py to + fix them. http://www.orcaware.com/svn/wiki/Svnmerge.py. The + basic procedure is: + + - get a svn copy of the branch (svn co + https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/branches/v0_91_maint) + and the trunk (svn co + https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/trunk/matplotlib) + + - Michael advises making the change on the branch and committing + it. Make sure you svn upped on the trunk and have no local + modifications, and then from the svn trunk do + + # where these are the revision numbers. ranges also acceptable + > svnmerge.py merge -rNNN1,NNN2 + # this file is automatically created by the merge command + > svn commit -F svnmerge-commit-message.txt + == Importing and name spaces == For numpy, use: + import numpy as np a = np.array([1,2,3]) Modified: trunk/matplotlib/lib/matplotlib/cbook.py =================================================================== --- trunk/matplotlib/lib/matplotlib/cbook.py 2008-05-17 21:30:23 UTC (rev 5179) +++ trunk/matplotlib/lib/matplotlib/cbook.py 2008-05-17 21:32:33 UTC (rev 5180) @@ -198,21 +198,25 @@ return dict([ (val, 1) for val in x]).keys() def iterable(obj): + 'return true if obj is iterable' try: len(obj) except: return 0 return 1 def is_string_like(obj): + 'return true if obj looks like a string' if hasattr(obj, 'shape'): return 0 try: obj + '' except (TypeError, ValueError): return 0 return 1 def is_writable_file_like(obj): + 'return true if obj looks like a file object' return hasattr(obj, 'write') and callable(obj.write) def is_scalar(obj): + 'return true if ob is not string like and is not iterable' return is_string_like(obj) or not iterable(obj) def is_numlike(obj): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jd...@us...> - 2008-05-17 21:39:52
|
Revision: 5182 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5182&view=rev Author: jdh2358 Date: 2008-05-17 14:39:46 -0700 (Sat, 17 May 2008) Log Message: ----------- Merged revisions 5181 via svnmerge from https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/branches/v0_91_maint ........ r5181 | jdh2358 | 2008-05-17 16:38:21 -0500 (Sat, 17 May 2008) | 1 line fixed some typos in the CODING_GUIDE ........ Modified Paths: -------------- trunk/matplotlib/CODING_GUIDE Property Changed: ---------------- trunk/matplotlib/ Property changes on: trunk/matplotlib ___________________________________________________________________ Name: svnmerge-integrated - /branches/v0_91_maint:1-4816,5172,5178-5179 + /branches/v0_91_maint:1-4816,5172,5178-5179,5181 Modified: trunk/matplotlib/CODING_GUIDE =================================================================== --- trunk/matplotlib/CODING_GUIDE 2008-05-17 21:38:21 UTC (rev 5181) +++ trunk/matplotlib/CODING_GUIDE 2008-05-17 21:39:46 UTC (rev 5182) @@ -41,11 +41,13 @@ MANIFEST.in. This file determines what goes into the src distribution of the mpl build. - * Keep the maintenance branch and trunk in sync here it makes sense. + * Keep the maintenance branch and trunk in sync where it makes sense. If there is a bug on both that needs fixing, use svnmerge.py to - fix them. http://www.orcaware.com/svn/wiki/Svnmerge.py. The + keep them in sync. http://www.orcaware.com/svn/wiki/Svnmerge.py. The basic procedure is: + - install svnmerge.py in your PATH + - get a svn copy of the branch (svn co https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/branches/v0_91_maint) and the trunk (svn co @@ -55,8 +57,9 @@ it. Make sure you svn upped on the trunk and have no local modifications, and then from the svn trunk do - # where these are the revision numbers. ranges also acceptable + # where the NNN are the revision numbers. ranges also acceptable > svnmerge.py merge -rNNN1,NNN2 + # this file is automatically created by the merge command > svn commit -F svnmerge-commit-message.txt This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jd...@us...> - 2008-05-19 01:10:14
|
Revision: 5190 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5190&view=rev Author: jdh2358 Date: 2008-05-18 18:10:11 -0700 (Sun, 18 May 2008) Log Message: ----------- Merged revisions 5189 via svnmerge from https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/branches/v0_91_maint ........ r5189 | jdh2358 | 2008-05-18 20:09:09 -0500 (Sun, 18 May 2008) | 1 line fixed missing get_filterrad ........ Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/image.py Property Changed: ---------------- trunk/matplotlib/ Property changes on: trunk/matplotlib ___________________________________________________________________ Name: svnmerge-integrated - /branches/v0_91_maint:1-4816,5172,5178-5179,5181 + /branches/v0_91_maint:1-4816,5172,5178-5179,5181,5189 Modified: trunk/matplotlib/lib/matplotlib/image.py =================================================================== --- trunk/matplotlib/lib/matplotlib/image.py 2008-05-19 01:09:09 UTC (rev 5189) +++ trunk/matplotlib/lib/matplotlib/image.py 2008-05-19 01:10:11 UTC (rev 5190) @@ -362,6 +362,7 @@ def get_filterrad(self): 'return the filterrad setting' + return self._filterrad class NonUniformImage(AxesImage): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2008-05-19 12:56:06
|
Revision: 5192 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5192&view=rev Author: mdboom Date: 2008-05-19 05:55:47 -0700 (Mon, 19 May 2008) Log Message: ----------- THIS MERGE IS NOT AS BIG AS IT LOOKS -- It is to correct an error where somehow the svnmerge history was lost. This merge is in fact only of r5191. I have left the revision ranges that svnmerge did here, but edited the log list to only include r5191. Merged revisions 4817-5171,5173-5177,5180,5182-5188,5190-5191 via svnmerge from https://matplotlib.svn.sf.net/svnroot/matplotlib/branches/v0_91_maint ........ r5191 | mdboom | 2008-05-19 08:12:30 -0400 (Mon, 19 May 2008) | 2 lines Use is_string_like instead of explicitly string or unicode. ........ Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/axes.py trunk/matplotlib/lib/matplotlib/backends/backend_agg.py Property Changed: ---------------- trunk/matplotlib/ Property changes on: trunk/matplotlib ___________________________________________________________________ Name: svnmerge-integrated - /branches/v0_91_maint:1-4816,5172,5178-5179,5181,5189 + /branches/v0_91_maint:1-5191 Modified: trunk/matplotlib/lib/matplotlib/axes.py =================================================================== --- trunk/matplotlib/lib/matplotlib/axes.py 2008-05-19 12:12:30 UTC (rev 5191) +++ trunk/matplotlib/lib/matplotlib/axes.py 2008-05-19 12:55:47 UTC (rev 5192) @@ -331,7 +331,6 @@ self.set_patchprops(seg, **kwargs) ret.append(seg) - if self.command == 'plot': func = makeline else: func = makefill if multicol: @@ -2818,7 +2817,6 @@ autoscaled; default True. See Axes.autoscale_view for more information """ - scalex = kwargs.pop( 'scalex', True) scaley = kwargs.pop( 'scaley', True) @@ -3757,7 +3755,7 @@ xlolims=False, xuplims=False, **kwargs): """ ERRORBAR(x, y, yerr=None, xerr=None, - fmt='b-', ecolor=None, elinewidth=None, capsize=3, + fmt='b-', ecolor=None, elinewidth=None, capsize=3, barsabove=False, lolims=False, uplims=False, xlolims=False, xuplims=False) @@ -5472,7 +5470,7 @@ if not self._hold: self.cla() n, bins = np.histogram(x, bins, range=None, normed=bool(normed), new=True) - + if cumulative: if normed: n = (n * np.diff(bins)).cumsum() Modified: trunk/matplotlib/lib/matplotlib/backends/backend_agg.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_agg.py 2008-05-19 12:12:30 UTC (rev 5191) +++ trunk/matplotlib/lib/matplotlib/backends/backend_agg.py 2008-05-19 12:55:47 UTC (rev 5192) @@ -289,7 +289,7 @@ renderer = self.get_renderer() original_dpi = renderer.dpi renderer.dpi = self.figure.dpi - if type(filename_or_obj) in (str, unicode): + if is_string_like(filename_or_obj): filename_or_obj = opefile(filename_or_obj, 'wb') renderer._renderer.write_rgba(filename_or_obj) renderer.dpi = original_dpi @@ -300,7 +300,7 @@ renderer = self.get_renderer() original_dpi = renderer.dpi renderer.dpi = self.figure.dpi - if type(filename_or_obj) in (str, unicode): + if is_string_like(filename_or_obj): filename_or_obj = file(filename_or_obj, 'wb') self.get_renderer()._renderer.write_png(filename_or_obj, self.figure.dpi) renderer.dpi = original_dpi This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2008-05-19 19:09:39
|
Revision: 5195 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5195&view=rev Author: mdboom Date: 2008-05-19 12:09:35 -0700 (Mon, 19 May 2008) Log Message: ----------- Merged revisions 5192-5193 via svnmerge from https://matplotlib.svn.sf.net/svnroot/matplotlib/branches/v0_91_maint ........ r5193 | mdboom | 2008-05-19 15:05:23 -0400 (Mon, 19 May 2008) | 3 lines [ 1966974 ] win32FontDirectory() can fail with access denied (Thanks, Patrik Simons) ........ Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/lib/matplotlib/font_manager.py Property Changed: ---------------- trunk/matplotlib/ Property changes on: trunk/matplotlib ___________________________________________________________________ Name: svnmerge-integrated - /branches/v0_91_maint:1-5191 + /branches/v0_91_maint:1-5193 Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2008-05-19 19:07:47 UTC (rev 5194) +++ trunk/matplotlib/CHANGELOG 2008-05-19 19:09:35 UTC (rev 5195) @@ -1,3 +1,6 @@ +2008-05-19 Fix crash when Windows can not access the registry to + determine font path [Bug 1966974, thanks Patrik Simons] - MGD + 2008-05-16 removed some unneeded code w/ the python 2.4 requirement. cbook no longer provides compatibility for reversed, enumerate, set or izip. removed lib/subprocess, mpl1, Modified: trunk/matplotlib/lib/matplotlib/font_manager.py =================================================================== --- trunk/matplotlib/lib/matplotlib/font_manager.py 2008-05-19 19:07:47 UTC (rev 5194) +++ trunk/matplotlib/lib/matplotlib/font_manager.py 2008-05-19 19:09:35 UTC (rev 5195) @@ -107,14 +107,17 @@ except ImportError: pass # Fall through to default else: - user = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, MSFolders) try: + user = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, MSFolders) try: - return _winreg.QueryValueEx(user, 'Fonts')[0] - except OSError: - pass # Fall through to default - finally: - _winreg.CloseKey(user) + try: + return _winreg.QueryValueEx(user, 'Fonts')[0] + except OSError: + pass # Fall through to default + finally: + _winreg.CloseKey(user) + except OSError: + pass # Fall through to default return os.path.join(os.environ['WINDIR'], 'Fonts') def win32InstalledFonts(directory=None, fontext='ttf'): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jd...@us...> - 2008-05-20 21:05:56
|
Revision: 5206 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5206&view=rev Author: jdh2358 Date: 2008-05-20 14:05:49 -0700 (Tue, 20 May 2008) Log Message: ----------- Merged revisions 5205 via svnmerge from https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/branches/v0_91_maint ........ r5205 | jdh2358 | 2008-05-20 16:02:08 -0500 (Tue, 20 May 2008) | 1 line remove pesky date auto xlabel ........ Modified Paths: -------------- trunk/matplotlib/CODING_GUIDE trunk/matplotlib/lib/matplotlib/dates.py Property Changed: ---------------- trunk/matplotlib/ Property changes on: trunk/matplotlib ___________________________________________________________________ Name: svnmerge-integrated - /branches/v0_91_maint:1-5193 + /branches/v0_91_maint:1-5205 Modified: trunk/matplotlib/CODING_GUIDE =================================================================== --- trunk/matplotlib/CODING_GUIDE 2008-05-20 21:02:08 UTC (rev 5205) +++ trunk/matplotlib/CODING_GUIDE 2008-05-20 21:05:49 UTC (rev 5206) @@ -46,7 +46,8 @@ keep them in sync. http://www.orcaware.com/svn/wiki/Svnmerge.py. The basic procedure is: - - install svnmerge.py in your PATH + - install svnmerge.py in your PATH: + wget http://svn.collab.net/repos/svn/trunk/contrib/client-side/svnmerge/svnmerge.py - get a svn copy of the branch (svn co https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/branches/v0_91_maint) Modified: trunk/matplotlib/lib/matplotlib/dates.py =================================================================== --- trunk/matplotlib/lib/matplotlib/dates.py 2008-05-20 21:02:08 UTC (rev 5205) +++ trunk/matplotlib/lib/matplotlib/dates.py 2008-05-20 21:05:49 UTC (rev 5206) @@ -997,7 +997,7 @@ return units.AxisInfo( majloc = majloc, majfmt = majfmt, - label='date', + label='', ) else: return None axisinfo = staticmethod(axisinfo) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mme...@us...> - 2008-05-21 09:50:39
|
Revision: 5208 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5208&view=rev Author: mmetz_bn Date: 2008-05-21 02:50:36 -0700 (Wed, 21 May 2008) Log Message: ----------- Merged revisions 5206-5207 via svnmerge from https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/branches/v0_91_maint ........ r5207 | mmetz_bn | 2008-05-21 11:47:59 +0200 (Wed, 21 May 2008) | 1 line Fixed bug in plotfile ........ Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/lib/matplotlib/pyplot.py Property Changed: ---------------- trunk/matplotlib/ Property changes on: trunk/matplotlib ___________________________________________________________________ Name: svnmerge-integrated - /branches/v0_91_maint:1-5205 + /branches/v0_91_maint:1-5207 Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2008-05-21 09:47:59 UTC (rev 5207) +++ trunk/matplotlib/CHANGELOG 2008-05-21 09:50:36 UTC (rev 5208) @@ -1,3 +1,5 @@ +2008-05-21 Fix a "local variable unreferenced" bug in plotfile - MM + 2008-05-19 Fix crash when Windows can not access the registry to determine font path [Bug 1966974, thanks Patrik Simons] - MGD Modified: trunk/matplotlib/lib/matplotlib/pyplot.py =================================================================== --- trunk/matplotlib/lib/matplotlib/pyplot.py 2008-05-21 09:47:59 UTC (rev 5207) +++ trunk/matplotlib/lib/matplotlib/pyplot.py 2008-05-21 09:50:36 UTC (rev 5208) @@ -40,7 +40,7 @@ def switch_backend(newbackend): """ - Swtich the default backend to newbackend. This feature is + Switch the default backend to newbackend. This feature is EXPERIMENTAL, and is only expected to work switching to an image backend. Eg, if you have a bunch of PS scripts that you want to run from an interactive ipython session, you may want to switch to @@ -1282,7 +1282,7 @@ xname, x = getname_val(cols[0]) if len(cols)==1: - ax1 = fig.add_subplot(N,1,i) + ax1 = fig.add_subplot(1,1,1) funcname = plotfuncs.get(cols[0], 'plot') func = getattr(ax1, funcname) func(x, **kwargs) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jd...@us...> - 2008-05-22 14:33:02
|
Revision: 5214 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5214&view=rev Author: jdh2358 Date: 2008-05-22 07:32:56 -0700 (Thu, 22 May 2008) Log Message: ----------- Merged revisions 5211,5213 via svnmerge from https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/branches/v0_91_maint ........ r5211 | mdboom | 2008-05-21 08:06:51 -0500 (Wed, 21 May 2008) | 2 lines Backport TkAgg segfault fix. ........ r5213 | jdh2358 | 2008-05-22 09:21:10 -0500 (Thu, 22 May 2008) | 1 line applied stans wx figsize patch ........ Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/lib/matplotlib/backends/backend_wx.py trunk/matplotlib/lib/matplotlib/figure.py Property Changed: ---------------- trunk/matplotlib/ Property changes on: trunk/matplotlib ___________________________________________________________________ Name: svnmerge-integrated - /branches/v0_91_maint:1-5207 + /branches/v0_91_maint:1-5213 Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2008-05-22 14:21:10 UTC (rev 5213) +++ trunk/matplotlib/CHANGELOG 2008-05-22 14:32:56 UTC (rev 5214) @@ -1,3 +1,5 @@ +2008-05-21 Fix segfault in TkAgg backend - MGD + 2008-05-21 Fix a "local variable unreferenced" bug in plotfile - MM 2008-05-19 Fix crash when Windows can not access the registry to Modified: trunk/matplotlib/lib/matplotlib/backends/backend_wx.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_wx.py 2008-05-22 14:21:10 UTC (rev 5213) +++ trunk/matplotlib/lib/matplotlib/backends/backend_wx.py 2008-05-22 14:32:56 UTC (rev 5214) @@ -1226,14 +1226,15 @@ pos =wx.Point(20,20) l,b,w,h = fig.bbox.bounds wx.Frame.__init__(self, parent=None, id=-1, pos=pos, - title="Figure %d" % num, - size=(w,h)) + title="Figure %d" % num) + # Frame will be sized later by the Fit method DEBUG_MSG("__init__()", 1, self) self.num = num statbar = StatusBarWx(self) self.SetStatusBar(statbar) self.canvas = self.get_canvas(fig) + self.canvas.SetInitialSize(wx.Size(fig.bbox.width(), fig.bbox.height())) self.sizer =wx.BoxSizer(wx.VERTICAL) self.sizer.Add(self.canvas, 1, wx.TOP | wx.LEFT | wx.EXPAND) # By adding toolbar in sizer, we are able to put it at the bottom @@ -1352,6 +1353,11 @@ def set_window_title(self, title): self.window.SetTitle(title) + def resize(self, width, height) + 'Set the canvas size in pixels' + self.canvas.SetInitialSize(wx.Size(width, height)) + self.window.GetSizer().Fit(self.window) + # Identifiers for toolbar controls - images_wx contains bitmaps for the images # used in the controls. wxWindows does not provide any stock images, so I've # 'stolen' those from GTK2, and transformed them into the appropriate format. Modified: trunk/matplotlib/lib/matplotlib/figure.py =================================================================== --- trunk/matplotlib/lib/matplotlib/figure.py 2008-05-22 14:21:10 UTC (rev 5213) +++ trunk/matplotlib/lib/matplotlib/figure.py 2008-05-22 14:32:56 UTC (rev 5214) @@ -414,6 +414,7 @@ from the shell WARNING: forward=True is broken on all backends except GTK* + and WX* ACCEPTS: a w,h tuple with w,h in inches """ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jd...@us...> - 2008-05-22 18:17:03
|
Revision: 5216 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5216&view=rev Author: jdh2358 Date: 2008-05-22 11:16:43 -0700 (Thu, 22 May 2008) Log Message: ----------- Merged revisions 5215 via svnmerge from https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/branches/v0_91_maint ........ r5215 | jdh2358 | 2008-05-22 13:14:59 -0500 (Thu, 22 May 2008) | 1 line fixed a wx bug ........ Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/backends/backend_wx.py Property Changed: ---------------- trunk/matplotlib/ Property changes on: trunk/matplotlib ___________________________________________________________________ Name: svnmerge-integrated - /branches/v0_91_maint:1-5213 + /branches/v0_91_maint:1-5215 Modified: trunk/matplotlib/lib/matplotlib/backends/backend_wx.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_wx.py 2008-05-22 18:14:59 UTC (rev 5215) +++ trunk/matplotlib/lib/matplotlib/backends/backend_wx.py 2008-05-22 18:16:43 UTC (rev 5216) @@ -1353,7 +1353,7 @@ def set_window_title(self, title): self.window.SetTitle(title) - def resize(self, width, height) + def resize(self, width, height): 'Set the canvas size in pixels' self.canvas.SetInitialSize(wx.Size(width, height)) self.window.GetSizer().Fit(self.window) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mme...@us...> - 2008-05-23 07:51:24
|
Revision: 5221 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5221&view=rev Author: mmetz_bn Date: 2008-05-23 00:51:20 -0700 (Fri, 23 May 2008) Log Message: ----------- Major hist() revision Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/examples/pylab/histogram_demo.py trunk/matplotlib/lib/matplotlib/axes.py Added Paths: ----------- trunk/matplotlib/examples/pylab/histogram_demo_extended.py Removed Paths: ------------- trunk/matplotlib/examples/pylab/histogram_demo_cumulative.py trunk/matplotlib/examples/pylab/histogram_demo_step.py Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2008-05-22 21:49:25 UTC (rev 5220) +++ trunk/matplotlib/CHANGELOG 2008-05-23 07:51:20 UTC (rev 5221) @@ -1,3 +1,8 @@ +2008-05-23 Major revision of hist(). Can handle 2D arrays and create + stacked histogram plots; keyword 'width' deprecated and + rwidth (relative width) introduced; align='edge' changed + to center of bin - MM + 2008-05-22 Added support for ReST-based doumentation using Sphinx. Documents are located in doc/, and are broken up into a users guide and an API reference. To build, run the Modified: trunk/matplotlib/examples/pylab/histogram_demo.py =================================================================== --- trunk/matplotlib/examples/pylab/histogram_demo.py 2008-05-22 21:49:25 UTC (rev 5220) +++ trunk/matplotlib/examples/pylab/histogram_demo.py 2008-05-23 07:51:20 UTC (rev 5221) @@ -1,23 +1,23 @@ #!/usr/bin/env python -from pylab import * +import pylab as P mu, sigma = 100, 15 -x = mu + sigma*randn(10000) +x = mu + sigma*P.randn(10000) # the histogram of the data -n, bins, patches = hist(x, 50, normed=1) -setp(patches, 'facecolor', 'g', 'alpha', 0.75) +n, bins, patches = P.hist(x, 50, normed=1) +P.setp(patches, 'facecolor', 'g', 'alpha', 0.75) # add a 'best fit' line -y = normpdf( bins, mu, sigma) -l = plot(bins, y, 'r--') -setp(l, 'linewidth', 1) +y = P.normpdf( bins, mu, sigma) +l = P.plot(bins, y, 'r--') +P.setp(l, 'linewidth', 1) -xlabel('Smarts') -ylabel('Probability') -title(r'$\mathrm{Histogram\ of\ IQ:}\ \mu=100,\ \sigma=15$') -axis([40, 160, 0, 0.03]) -grid(True) +P.xlabel('Smarts') +P.ylabel('Probability') +P.title(r'$\mathrm{Histogram\ of\ IQ:}\ \mu=100,\ \sigma=15$') +P.axis([40, 160, 0, 0.03]) +P.grid(True) -#savefig('histogram_demo',dpi=72) -show() +#P.savefig('histogram_demo',dpi=72) +P.show() Deleted: trunk/matplotlib/examples/pylab/histogram_demo_cumulative.py =================================================================== --- trunk/matplotlib/examples/pylab/histogram_demo_cumulative.py 2008-05-22 21:49:25 UTC (rev 5220) +++ trunk/matplotlib/examples/pylab/histogram_demo_cumulative.py 2008-05-23 07:51:20 UTC (rev 5221) @@ -1,33 +0,0 @@ -#!/usr/bin/env python -from pylab import * - -mu, sigma = 100, 25 -x = mu + sigma*randn(10000) - -# the histogram of the data -n, bins, patches = hist(x, 50, normed=1, histtype='step', cumulative=True) -setp(patches, 'facecolor', 'g', 'alpha', 0.75) - -# add a 'best fit' line -y = normpdf( bins, mu, sigma).cumsum() -y /= y[-1] -l = plot(bins, y, 'k--', linewidth=1.5) - -# overlay the first histogram with a second one -# were the data has a smaller standard deviation -mu, sigma = 100, 10 -x = mu + sigma*randn(10000) - -n, bins, patches = hist(x, bins=bins, normed=1, histtype='step', cumulative=True) -setp(patches, 'facecolor', 'r', 'alpha', 0.25) - -# add a 'best fit' line -y = normpdf( bins, mu, sigma).cumsum() -y /= y[-1] -l = plot(bins, y, 'k--', linewidth=1.5) - -grid(True) -ylim(0, 1.1) - -#savefig('histogram_demo',dpi=72) -show() \ No newline at end of file Added: trunk/matplotlib/examples/pylab/histogram_demo_extended.py =================================================================== --- trunk/matplotlib/examples/pylab/histogram_demo_extended.py (rev 0) +++ trunk/matplotlib/examples/pylab/histogram_demo_extended.py 2008-05-23 07:51:20 UTC (rev 5221) @@ -0,0 +1,79 @@ +#!/usr/bin/env python +import pylab as P + +# +# The hist() function now has a lot more options +# + +# +# first create a single histogram +# +mu, sigma = 200, 25 +x = mu + sigma*P.randn(10000) + +# the histogram of the data with histtype='step' +n, bins, patches = P.hist(x, 50, normed=1, histtype='step') +P.setp(patches, 'facecolor', 'g', 'alpha', 0.75) + +# add a line showing the expected distribution +y = P.normpdf( bins, mu, sigma) +l = P.plot(bins, y, 'k--', linewidth=1.5) + + +# +# create a histogram by providing the bin edges (unequally spaced) +# +P.figure() + +bins = [100,125,150,160,170,180,190,200,210,220,230,240,250,275,300] +# the histogram of the data with histtype='step' +n, bins, patches = P.hist(x, bins, normed=1, histtype='bar', rwidth=0.8) + +# +# now we create a cumulative histogram of the data +# +P.figure() + +n, bins, patches = P.hist(x, 50, normed=1, histtype='step', cumulative=True) +P.setp(patches, 'facecolor', 'b', 'alpha', 0.75) + +# add a line showing the expected distribution +y = P.normpdf( bins, mu, sigma).cumsum() +y /= y[-1] +l = P.plot(bins, y, 'k--', linewidth=1.5) + +# create a second data-set with a smaller standard deviation +sigma2 = 15. +x = mu + sigma2*P.randn(10000) + +n, bins, patches = P.hist(x, bins=bins, normed=1, histtype='step', cumulative=True) +P.setp(patches, 'facecolor', 'r', 'alpha', 0.5) + +# add a line showing the expected distribution +y = P.normpdf( bins, mu, sigma2).cumsum() +y /= y[-1] +l = P.plot(bins, y, 'r--', linewidth=1.5) + +P.grid(True) +P.ylim(0, 1.05) + + +# +# histogram has the ability to plot multiple data in parallel ... +# +P.figure() + +# create a new data-set +x = mu + sigma*P.randn(1000,3) + +n, bins, patches = P.hist(x, 10, normed=1, histtype='bar') + +# +# ... or we can stack the data +# +P.figure() + +n, bins, patches = P.hist(x, 10, normed=1, histtype='barstacked') + + +P.show() \ No newline at end of file Deleted: trunk/matplotlib/examples/pylab/histogram_demo_step.py =================================================================== --- trunk/matplotlib/examples/pylab/histogram_demo_step.py 2008-05-22 21:49:25 UTC (rev 5220) +++ trunk/matplotlib/examples/pylab/histogram_demo_step.py 2008-05-23 07:51:20 UTC (rev 5221) @@ -1,31 +0,0 @@ -#!/usr/bin/env python -from pylab import * - -mu, sigma = 100, 15 -x = mu + sigma*randn(10000) - -# the histogram of the data -n, bins, patches = hist(x, 50, normed=1, histtype='step') -setp(patches, 'facecolor', 'g', 'alpha', 0.75) - -# add a 'best fit' line -y = normpdf( bins, mu, sigma) -l = plot(bins, y, 'k--', linewidth=1) - - -# overlay the first histogram with a second one -# were the data has a smaller standard deviation -mu, sigma = 100, 5 -x = mu + sigma*randn(10000) - -n, bins, patches = hist(x, 50, normed=1, histtype='step') -setp(patches, 'facecolor', 'r', 'alpha', 0.25) - -y = normpdf( bins, mu, sigma) -l = plot(bins, y, 'k--', linewidth=1) - -axis([40, 160, 0, 0.09]) -grid(True) - -#savefig('histogram_demo',dpi=72) -show() Modified: trunk/matplotlib/lib/matplotlib/axes.py =================================================================== --- trunk/matplotlib/lib/matplotlib/axes.py 2008-05-22 21:49:25 UTC (rev 5220) +++ trunk/matplotlib/lib/matplotlib/axes.py 2008-05-23 07:51:20 UTC (rev 5221) @@ -5392,7 +5392,8 @@ right """ - ax2 = self.figure.add_axes(self.get_position(True), sharex=self, frameon=False) + ax2 = self.figure.add_axes(self.get_position(True), sharex=self, + frameon=False) ax2.yaxis.tick_right() ax2.yaxis.set_label_position('right') self.yaxis.tick_left() @@ -5408,7 +5409,8 @@ top """ - ax2 = self.figure.add_axes(self.get_position(True), sharey=self, frameon=False) + ax2 = self.figure.add_axes(self.get_position(True), sharey=self, + frameon=False) ax2.xaxis.tick_top() ax2.xaxis.set_label_position('top') self.xaxis.tick_bottom() @@ -5420,16 +5422,19 @@ def hist(self, x, bins=10, normed=False, cumulative=False, bottom=None, histtype='bar', align='edge', - orientation='vertical', width=None, log=False, **kwargs): + orientation='vertical', rwidth=None, log=False, **kwargs): """ HIST(x, bins=10, normed=False, cumulative=False, bottom=None, histtype='bar', align='edge', - orientation='vertical', width=None, log=False, **kwargs) + orientation='vertical', rwidth=None, log=False, **kwargs) Compute the histogram of x. bins is either an integer number of bins or a sequence giving the bins. x are the data to be binned. + x can be an array or a 2D array with multiple data in its columns. - The return values is (n, bins, patches) + The return values is (n, bins, patches) or + ([n0,n1,...], bins, [patches0,patches1,...]) if the input + contains multiple data. If normed is true, the first element of the return tuple will be the counts normalized to form a probability density, ie, @@ -5442,22 +5447,25 @@ If cumulative is True then a histogram is computed where each bin gives the counts in that bin plus all bins for smaller values. - The last bins gives the total number of datapoints. If normed is + The last bin gives the total number of datapoints. If normed is also True then the histogram is normalized such that the last bin equals one. - histtype = 'bar' | 'step'. The type of histogram to draw. - 'bar' is a traditional bar-type histogram, 'step' generates - a lineplot. + histtype = 'bar' | 'barstacked' | 'step'. The type of histogram + to draw. 'bar' is a traditional bar-type histogram, 'barstacked' + is a bar-type histogram where multiple data are stacked on top + of each other, and 'step' generates a lineplot. - align = 'edge' | 'center'. Interprets bins either as edge - or center values + align controles how the histogram is plotted + - 'edge' : bars are centered between the bin edges + - 'center': bars are centered on the left bin edges orientation = 'horizontal' | 'vertical'. If horizontal, barh will be used and the "bottom" kwarg will be the left edges. - width: the width of the bars. If None, automatically compute - the width. Ignored for 'step' histtype. + rwidth: the relative width of the bars as fraction of the bin + width. If None, automatically compute the width. Ignored + for 'step' histtype. log: if True, the histogram axis will be set to a log scale @@ -5466,25 +5474,86 @@ %(Rectangle)s """ if not self._hold: self.cla() - n, bins = np.histogram(x, bins, range=None, - normed=bool(normed), new=True) + if kwargs.get('width') is not None: + raise DeprecationWarning( + 'hist now uses the rwidth to give relative width and not absolute width') + + # todo: make hist() work with list of arrays with different lengths + x = np.asarray(x) + if len(x.shape)==2: + n = [] + for i in xrange(x.shape[1]): + # this will automatically overwrite bins, + # so that each histogram uses the same bins + m, bins = np.histogram(x[:,i], bins, range=None, + normed=bool(normed), new=True) + n.append(m) + else: + n, bins = np.histogram(x, bins, range=None, + normed=bool(normed), new=True) + n = [n,] + if cumulative: if normed: - n = (n * np.diff(bins)).cumsum() + n = [(m * np.diff(bins)).cumsum() for m in n] else: - n = n.cumsum() + n = [m.cumsum() for m in n] - if histtype == 'bar': - if width is None: - width = 0.9*(bins[1]-bins[0]) + ccount = 0 + colors = _process_plot_var_args.defaultColors[:] + patches = [] + if histtype.startswith('bar'): + totwidth = np.diff(bins) + stacked = False + + if rwidth is not None: dr = min(1., max(0., rwidth)) + elif len(n)>1: dr = 0.8 + else: dr = 1.0 + + if histtype=='bar': + width = dr*totwidth/len(n) + dw = width + + if len(n)>1: + boffset = -0.5*dr*totwidth*(1.-1./len(n)) + else: + boffset = 0.0 + elif histtype=='barstacked': + width = dr*totwidth + boffset, dw = 0.0, 0.0 + + stacked = True + if bottom is None: bottom = 0.0 + else: + raise ValueError, 'invalid histtype: %s' % histtype + + if align=='edge': + boffset += 0.5*totwidth + elif align != 'center': + raise ValueError, 'invalid align: %s' % align + if orientation == 'horizontal': - patches = self.barh(bins[:-1], n, height=width, left=bottom, - align=align, log=log) + for m in n: + color = colors[ccount % len(colors)] + patch = self.barh(bins[:-1]+boffset, m, height=width, + left=bottom, align='center', log=log, + color=color) + patches.append(patch) + if stacked: bottom += m + boffset += dw + ccount += 1 elif orientation == 'vertical': - patches = self.bar(bins[:-1], n, width=width, bottom=bottom, - align=align, log=log) + for m in n: + color = colors[ccount % len(colors)] + patch = self.bar(bins[:-1]+boffset, m, width=width, + bottom=bottom, align='center', log=log, + color=color) + patches.append(patch) + if stacked: bottom += m + boffset += dw + ccount += 1 else: raise ValueError, 'invalid orientation: %s' % orientation @@ -5493,22 +5562,29 @@ y = np.zeros( 2*len(bins), np.float_ ) x[0::2], x[1::2] = bins, bins - y[1:-1:2], y[2::2] = n, n if align == 'center': x -= 0.5*(bins[1]-bins[0]) + elif align != 'edge': + raise ValueError, 'invalid align: %s' % align - if orientation == 'horizontal': - x,y = y,x - elif orientation != 'vertical': - raise ValueError, 'invalid orientation: %s' % orientation - patches = self.fill(x,y) + for m in n: + y[1:-1:2], y[2::2] = m, m + if orientation == 'horizontal': + x,y = y,x + elif orientation != 'vertical': + raise ValueError, 'invalid orientation: %s' % orientation + patches.append( self.fill(x,y) ) else: raise ValueError, 'invalid histtype: %s' % histtype - - for p in patches: - p.update(kwargs) - return n, bins, cbook.silent_list('Patch', patches) + + for patch in patches: + for p in patch: + p.update(kwargs) + if len(n)==1: + return n[0], bins, cbook.silent_list('Patch', patches[0]) + else: + return n, bins, cbook.silent_list('Lists of Patches', patches) hist.__doc__ = cbook.dedent(hist.__doc__) % martist.kwdocd def psd(self, x, NFFT=256, Fs=2, Fc=0, detrend=mlab.detrend_none, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jd...@us...> - 2008-05-23 23:18:02
|
Revision: 5248 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5248&view=rev Author: jdh2358 Date: 2008-05-23 16:17:57 -0700 (Fri, 23 May 2008) Log Message: ----------- fixed a hist bug with 1xN inputs Modified Paths: -------------- trunk/matplotlib/examples/pylab/mri_with_eeg.py trunk/matplotlib/lib/matplotlib/axes.py Modified: trunk/matplotlib/examples/pylab/mri_with_eeg.py =================================================================== --- trunk/matplotlib/examples/pylab/mri_with_eeg.py 2008-05-23 21:53:33 UTC (rev 5247) +++ trunk/matplotlib/examples/pylab/mri_with_eeg.py 2008-05-23 23:17:57 UTC (rev 5248) @@ -27,6 +27,7 @@ im = take(im, nonzero(im)) # ignore the background im = im/(2.0**15) # normalize hist(im, 100) + print im.shape xticks([-1, -.5, 0, .5, 1]) yticks([]) xlabel('intensity') @@ -84,6 +85,7 @@ xlabel('time (s)') +if 1: + savefig('mri_with_eeg') -#savefig('mri_with_eeg') show() Modified: trunk/matplotlib/lib/matplotlib/axes.py =================================================================== --- trunk/matplotlib/lib/matplotlib/axes.py 2008-05-23 21:53:33 UTC (rev 5247) +++ trunk/matplotlib/lib/matplotlib/axes.py 2008-05-23 23:17:57 UTC (rev 5248) @@ -5484,8 +5484,15 @@ 'hist now uses the rwidth to give relative width and not absolute width') # todo: make hist() work with list of arrays with different lengths - x = np.asarray(x) + x = np.asarray(x).copy() + if len(x.shape)==2 and min(x.shape)==1: + x.shape = max(x.shape), + + if len(x.shape)==2 and x.shape[0]<x.shape[1]: + warnings.warn('2D hist should be nsamples x nvariables; this looks transposed') + if len(x.shape)==2: + n = [] for i in xrange(x.shape[1]): # this will automatically overwrite bins, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ef...@us...> - 2008-05-24 07:36:51
|
Revision: 5250 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5250&view=rev Author: efiring Date: 2008-05-24 00:36:47 -0700 (Sat, 24 May 2008) Log Message: ----------- Provide function and method to control the plot color cycle Modified Paths: -------------- trunk/matplotlib/API_CHANGES trunk/matplotlib/CHANGELOG trunk/matplotlib/examples/tests/backend_driver.py trunk/matplotlib/lib/matplotlib/axes.py Modified: trunk/matplotlib/API_CHANGES =================================================================== --- trunk/matplotlib/API_CHANGES 2008-05-24 00:51:33 UTC (rev 5249) +++ trunk/matplotlib/API_CHANGES 2008-05-24 07:36:47 UTC (rev 5250) @@ -1,3 +1,7 @@ + New axes function and Axes method provide control over the plot + color cycle: axes.set_default_color_cycle(clist) and + Axes.set_color_cycle(clist). + matplotlib now requires python2.4, so matplotlib.cbook will no loner provide set, enumerate, reversed or izip compatability functions @@ -2,3 +6,3 @@ In numpy 1.0 bins are specified by the left edges only. The axes - method "hist" now uses future numpy 1.3 semantic for histograms. + method "hist" now uses future numpy 1.3 semantic for histograms. Providing binedges, the last value gives the upper-right edge now, Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2008-05-24 00:51:33 UTC (rev 5249) +++ trunk/matplotlib/CHANGELOG 2008-05-24 07:36:47 UTC (rev 5250) @@ -1,3 +1,6 @@ +2008-05-23 Provided a function and a method for controlling the + plot color cycle. - EF + 2008-05-23 Major revision of hist(). Can handle 2D arrays and create stacked histogram plots; keyword 'width' deprecated and rwidth (relative width) introduced; align='edge' changed Modified: trunk/matplotlib/examples/tests/backend_driver.py =================================================================== --- trunk/matplotlib/examples/tests/backend_driver.py 2008-05-24 00:51:33 UTC (rev 5249) +++ trunk/matplotlib/examples/tests/backend_driver.py 2008-05-24 07:36:47 UTC (rev 5250) @@ -114,6 +114,7 @@ api_dir = os.path.join('..', 'api') api_files = [ 'colorbar_only.py', + 'color_cycle.py', ] Modified: trunk/matplotlib/lib/matplotlib/axes.py =================================================================== --- trunk/matplotlib/lib/matplotlib/axes.py 2008-05-24 00:51:33 UTC (rev 5249) +++ trunk/matplotlib/lib/matplotlib/axes.py 2008-05-24 07:36:47 UTC (rev 5250) @@ -135,6 +135,18 @@ return linestyle, marker, color +def set_default_color_cycle(clist): + """ + Change the default cycle of colors that will be used by the plot + command. This must be called before creating the Axes to which + it will apply; it will apply to all future Axes. + + clist is a sequence of mpl color specifiers + + """ + _process_plot_var_args.defaultColors = clist[:] + rcParams['lines.color'] = clist[0] + class _process_plot_var_args: """ @@ -170,6 +182,12 @@ self.count = 0 + def set_color_cycle(self, clist): + self.colors = clist[:] + self.firstColor = self.colors[0] + self.Ncolors = len(self.colors) + self.count = 0 + def _get_next_cycle_color(self): if self.count==0: color = self.firstColor @@ -828,6 +846,15 @@ 'clear the axes' self.cla() + def set_color_cycle(self, clist): + """ + Set the color cycle for any future plot commands on this Axes. + + clist is a list of mpl color specifiers. + """ + self._get_lines.set_color_cycle(clist) + + def ishold(self): 'return the HOLD status of the axes' return self._hold This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jd...@us...> - 2008-05-24 17:56:20
|
Revision: 5252 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5252&view=rev Author: jdh2358 Date: 2008-05-24 10:55:54 -0700 (Sat, 24 May 2008) Log Message: ----------- fixed a wx bug and added PIL support to imread Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/lib/matplotlib/backends/backend_wx.py trunk/matplotlib/lib/matplotlib/image.py trunk/matplotlib/lib/matplotlib/patches.py Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2008-05-24 07:43:13 UTC (rev 5251) +++ trunk/matplotlib/CHANGELOG 2008-05-24 17:55:54 UTC (rev 5252) @@ -1,3 +1,6 @@ +2008-05-24 Added PIL support for loading images to imread (if PIL is + available) - JDH + 2008-05-23 Provided a function and a method for controlling the plot color cycle. - EF Modified: trunk/matplotlib/lib/matplotlib/backends/backend_wx.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_wx.py 2008-05-24 07:43:13 UTC (rev 5251) +++ trunk/matplotlib/lib/matplotlib/backends/backend_wx.py 2008-05-24 17:55:54 UTC (rev 5252) @@ -1234,7 +1234,7 @@ statbar = StatusBarWx(self) self.SetStatusBar(statbar) self.canvas = self.get_canvas(fig) - self.canvas.SetInitialSize(wx.Size(fig.bbox.width(), fig.bbox.height())) + self.canvas.SetInitialSize(wx.Size(fig.bbox.width, fig.bbox.height)) self.sizer =wx.BoxSizer(wx.VERTICAL) self.sizer.Add(self.canvas, 1, wx.TOP | wx.LEFT | wx.EXPAND) # By adding toolbar in sizer, we are able to put it at the bottom Modified: trunk/matplotlib/lib/matplotlib/image.py =================================================================== --- trunk/matplotlib/lib/matplotlib/image.py 2008-05-24 07:43:13 UTC (rev 5251) +++ trunk/matplotlib/lib/matplotlib/image.py 2008-05-24 17:55:54 UTC (rev 5252) @@ -652,13 +652,29 @@ Return value is a MxNx4 array of 0-1 normalized floats + matplotlib can only read PNGs natively, but if PIL is installed, + it will use it to load the image and return an RGBA if possible + which can be used with imshow """ + + def pilread(): + 'try to load the image with PIL or return None' + try: import Image + except ImportError: return None + image = Image.open( fname ) + return pil_to_array(image) + + handlers = {'png' :_image.readpng, } basename, ext = os.path.splitext(fname) ext = ext.lower()[1:] + if ext not in handlers.keys(): - raise ValueError('Only know how to handled extensions: %s' % handlers.keys()) + im = pilread() + if im is None: + raise ValueError('Only know how to handle extensions: %s; with PIL installed matplotlib can handle more images' % handlers.keys()) + return im handler = handlers[ext] return handler(fname) Modified: trunk/matplotlib/lib/matplotlib/patches.py =================================================================== --- trunk/matplotlib/lib/matplotlib/patches.py 2008-05-24 07:43:13 UTC (rev 5251) +++ trunk/matplotlib/lib/matplotlib/patches.py 2008-05-24 17:55:54 UTC (rev 5252) @@ -11,8 +11,8 @@ from matplotlib.path import Path # these are not available for the object inspector until after the -# class is build so we define an initial set here for the init -# function and they will be overridden after object defn +# class is built so we define an initial set here for the init +# function and they will be overridden after object definition artist.kwdocd['Patch'] = """\ alpha: float animated: [True | False] @@ -31,7 +31,6 @@ visible: [True | False] zorder: any number """ - class Patch(artist.Artist): """ A patch is a 2D thingy with a face color and an edge color @@ -1109,7 +1108,6 @@ r.draw(renderer) artist.kwdocd['Patch'] = patchdoc = artist.kwdoc(Patch) - for k in ('Rectangle', 'Circle', 'RegularPolygon', 'Polygon', 'Wedge', 'Arrow', 'FancyArrow', 'YAArrow', 'CirclePolygon', 'Ellipse'): artist.kwdocd[k] = patchdoc This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jd...@us...> - 2008-05-24 20:49:35
|
Revision: 5253 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5253&view=rev Author: jdh2358 Date: 2008-05-24 13:49:31 -0700 (Sat, 24 May 2008) Log Message: ----------- added new docs dir Added Paths: ----------- trunk/matplotlib/docs/ trunk/matplotlib/docs/_static/ trunk/matplotlib/docs/_templates/ trunk/matplotlib/docs/api/ trunk/matplotlib/docs/api/artist_api.rst trunk/matplotlib/docs/api/index.rst trunk/matplotlib/docs/conf.py trunk/matplotlib/docs/devel/ trunk/matplotlib/docs/devel/add_new_projection.rst trunk/matplotlib/docs/devel/coding_guide.rst trunk/matplotlib/docs/devel/documenting_mpl.rst trunk/matplotlib/docs/devel/index.rst trunk/matplotlib/docs/index.rst trunk/matplotlib/docs/make.py trunk/matplotlib/docs/mpl_data trunk/matplotlib/docs/mpl_examples trunk/matplotlib/docs/sphinxext/ trunk/matplotlib/docs/sphinxext/ipython_console_highlighting.py trunk/matplotlib/docs/sphinxext/mathml.py trunk/matplotlib/docs/sphinxext/mathpng.py trunk/matplotlib/docs/users/ trunk/matplotlib/docs/users/artists.rst trunk/matplotlib/docs/users/customizing.rst trunk/matplotlib/docs/users/event_handling.rst trunk/matplotlib/docs/users/figures/ trunk/matplotlib/docs/users/figures/dollar_ticks.py trunk/matplotlib/docs/users/figures/fig_axes_customize_simple.py trunk/matplotlib/docs/users/figures/fig_axes_labels_simple.py trunk/matplotlib/docs/users/figures/fig_x.py trunk/matplotlib/docs/users/figures/make.py trunk/matplotlib/docs/users/figures/pyplot_formatstr.py trunk/matplotlib/docs/users/figures/pyplot_mathtext.py trunk/matplotlib/docs/users/figures/pyplot_simple.py trunk/matplotlib/docs/users/figures/pyplot_text.py trunk/matplotlib/docs/users/figures/pyplot_three.py trunk/matplotlib/docs/users/figures/pyplot_two_subplots.py trunk/matplotlib/docs/users/index.rst trunk/matplotlib/docs/users/navigation_toolbar.rst trunk/matplotlib/docs/users/pyplot_tutorial.rst Added: trunk/matplotlib/docs/api/artist_api.rst =================================================================== --- trunk/matplotlib/docs/api/artist_api.rst (rev 0) +++ trunk/matplotlib/docs/api/artist_api.rst 2008-05-24 20:49:31 UTC (rev 5253) @@ -0,0 +1,31 @@ +****************** +matplotlib artists +****************** + +:mod:`matplotlib.artist` +============================= + +.. automodule:: matplotlib.artist + :members: + :undoc-members: + +:mod:`matplotlib.lines` +============================= + +.. automodule:: matplotlib.lines + :members: + :undoc-members: + +:mod:`matplotlib.patches` +============================= + +.. automodule:: matplotlib.patches + :members: + :undoc-members: + +:mod:`matplotlib.text` +============================= + +.. automodule:: matplotlib.text + :members: + :undoc-members: Added: trunk/matplotlib/docs/api/index.rst =================================================================== --- trunk/matplotlib/docs/api/index.rst (rev 0) +++ trunk/matplotlib/docs/api/index.rst 2008-05-24 20:49:31 UTC (rev 5253) @@ -0,0 +1,15 @@ +.. _api-index: + +#################### + The Matplotlib API +#################### + +:Release: |version| +:Date: |today| + +Introduction to developer's guide here **TODO**. + +.. toctree:: + + artist_api.rst + Added: trunk/matplotlib/docs/conf.py =================================================================== --- trunk/matplotlib/docs/conf.py (rev 0) +++ trunk/matplotlib/docs/conf.py 2008-05-24 20:49:31 UTC (rev 5253) @@ -0,0 +1,159 @@ +# -*- coding: utf-8 -*- +# +# Matplotlib documentation build configuration file, created by +# sphinx-quickstart on Fri May 2 12:33:25 2008. +# +# This file is execfile()d with the current directory set to its containing dir. +# +# The contents of this file are pickled, so don't put values in the namespace +# that aren't pickleable (module imports are okay, they're removed automatically). +# +# All configuration values have a default value; values that are commented out +# serve to show the default value. + +import sys, os + +# If your extensions are in another directory, add it here. If the directory +# is relative to the documentation root, use os.path.abspath to make it +# absolute, like shown here. +sys.path.append(os.path.abspath('sphinxext')) + +# Import support for ipython console session syntax highlighting (lives +# in the sphinxext directory defined above) +import ipython_console_highlighting + +# General configuration +# --------------------- + +# Add any Sphinx extension module names here, as strings. They can be extensions +# coming with Sphinx (named 'sphinx.ext.*') or your custom ones. +extensions = ['mathpng', 'sphinx.ext.autodoc'] + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['_templates'] + +# The suffix of source filenames. +source_suffix = '.rst' + +# The master toctree document. +master_doc = 'index' + +# General substitutions. +project = 'Matplotlib' +copyright = '2008, John Hunter, Darren Dale, Michael Droettboom' + +# The default replacements for |version| and |release|, also used in various +# other places throughout the built documents. +# +# The short X.Y version. +version = '0.98' +# The full version, including alpha/beta/rc tags. +release = '0.98pre' + +# There are two options for replacing |today|: either, you set today to some +# non-false value, then it is used: +#today = '' +# Else, today_fmt is used as the format for a strftime call. +today_fmt = '%B %d, %Y' + +# List of documents that shouldn't be included in the build. +unused_docs = [] + +# If true, '()' will be appended to :func: etc. cross-reference text. +#add_function_parentheses = True + +# If true, the current module name will be prepended to all description +# unit titles (such as .. function::). +#add_module_names = True + +# If true, sectionauthor and moduleauthor directives will be shown in the +# output. They are ignored by default. +#show_authors = False + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = 'sphinx' + + +# Options for HTML output +# ----------------------- + +# The style sheet to use for HTML and HTML Help pages. A file of that name +# must exist either in Sphinx' static/ path, or in one of the custom paths +# given in html_static_path. +html_style = 'default.css' + +# The name for this set of Sphinx documents. If None, it defaults to +# "<project> v<release> documentation". +#html_title = None + +# The name of an image file (within the static path) to place at the top of +# the sidebar. +#html_logo = 'logo.png' + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ['_static'] + +# If nonempty, this is the file name suffix for generated HTML files. The +# default is ``".html"``. +#html_file_suffix = '.xhtml' + +# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, +# using the given strftime format. +html_last_updated_fmt = '%b %d, %Y' + +# If true, SmartyPants will be used to convert quotes and dashes to +# typographically correct entities. +#html_use_smartypants = True + +# Custom sidebar templates, maps document names to template names. +#html_sidebars = {} + +# Additional templates that should be rendered to pages, maps page names to +# template names. +#html_additional_pages = {} + +# If false, no module index is generated. +#html_use_modindex = True + +# If true, the reST sources are included in the HTML build as _sources/<name>. +#html_copy_source = True + +# If true, an OpenSearch description file will be output, and all pages will +# contain a <link> tag referring to it. +html_use_opensearch = 'False' + +# Output file base name for HTML help builder. +htmlhelp_basename = 'Matplotlibdoc' + + +# Options for LaTeX output +# ------------------------ + +# The paper size ('letter' or 'a4'). +latex_paper_size = 'letter' + +# The font size ('10pt', '11pt' or '12pt'). +latex_font_size = '11pt' + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, author, document class [howto/manual]). +latex_documents = [ + ('index', 'Matplotlib.tex', 'Matplotlib', 'John Hunter, Darren Dale', 'Michael Droettboom', 'manual'), +] + +# The name of an image file (relative to this directory) to place at the top of +# the title page. +latex_logo = None + +# Additional stuff for the LaTeX preamble. +latex_preamble = '' + +# Documents to append as an appendix to all manuals. +latex_appendices = [] + +# If false, no module index is generated. +latex_use_modindex = True + +latex_use_parts = True Added: trunk/matplotlib/docs/devel/add_new_projection.rst =================================================================== --- trunk/matplotlib/docs/devel/add_new_projection.rst (rev 0) +++ trunk/matplotlib/docs/devel/add_new_projection.rst 2008-05-24 20:49:31 UTC (rev 5253) @@ -0,0 +1,105 @@ +*********************************************** +Adding new scales and projections to matplotlib +*********************************************** + +.. ::author Michael Droettboom + +Matplotlib supports the addition of custom procedures that transform +the data before it is displayed. + +There is an important distinction between two kinds of +transformations. Separable transformations, working on a single +dimension, are called "scales", and non-separable transformations, +that handle data in two or more dimensions at a time, are called +"projections". + +From the user's perspective, the scale of a plot can be set with +:meth:`~matplotlib.axes.Axes.set_xscale` and +:meth:`~matplotlib.axes.Axes.set_xscale`. Projections can be chosen +using the ``projection`` keyword argument to the +:func:`~matplotlib.pylab.plot` or :func:`~matplotlib.pylab.subplot` +functions, e.g.:: + + plot(x, y, projection="custom") + +This document is intended for developers and advanced users who need +to create new scales and projections for matplotlib. The necessary +code for scales and projections can be included anywhere: directly +within a plot script, in third-party code, or in the matplotlib source +tree itself. + + +Creating a new scale +==================== + +Adding a new scale consists of defining a subclass of +:class:`matplotlib.scale.ScaleBase`, that includes the following +elements: + + - A transformation from data coordinates into display coordinates. + + - An inverse of that transformation. This is used, for example, to + convert mouse positions from screen space back into data space. + + - A function to limit the range of the axis to acceptable values + (``limit_range_for_scale()``). A log scale, for instance, would + prevent the range from including values less than or equal to + zero. + + - Locators (major and minor) that determine where to place ticks in + the plot, and optionally, how to adjust the limits of the plot to + some "good" values. Unlike ``limit_range_for_scale()``, which is + always enforced, the range setting here is only used when + automatically setting the range of the plot. + + - Formatters (major and minor) that specify how the tick labels + should be drawn. + +Once the class is defined, it must be registered with matplotlib so +that the user can select it. + +A full-fledged and heavily annotated example is in +:file:`examples/api/custom_scale_example.py`. There are also some classes +in :mod:`matplotlib.scale` that may be used as starting points. + + +Creating a new projection +========================= + +Adding a new projection consists of defining a subclass of +:class:`matplotlib.axes.Axes`, that includes the following elements: + + - A transformation from data coordinates into display coordinates. + + - An inverse of that transformation. This is used, for example, to + convert mouse positions from screen space back into data space. + + - Transformations for the gridlines, ticks and ticklabels. Custom + projections will often need to place these elements in special + locations, and matplotlib has a facility to help with doing so. + + - Setting up default values (overriding + :meth:`~matplotlib.axes.Axes.cla`), since the defaults for a + rectilinear axes may not be appropriate. + + - Defining the shape of the axes, for example, an elliptical axes, + that will be used to draw the background of the plot and for + clipping any data elements. + + - Defining custom locators and formatters for the projection. For + example, in a geographic projection, it may be more convenient to + display the grid in degrees, even if the data is in radians. + + - Set up interactive panning and zooming. This is left as an + "advanced" feature left to the reader, but there is an example of + this for polar plots in :mod:`matplotlib.projections.polar`. + + - Any additional methods for additional convenience or features. + +Once the class is defined, it must be registered with matplotlib +so that the user can select it. + +A full-fledged and heavily annotated example is in +:file:`examples/api/custom_projection_example.py`. The polar plot +functionality in :mod:`matplotlib.projections.polar` may also be of +interest. Added: trunk/matplotlib/docs/devel/coding_guide.rst =================================================================== --- trunk/matplotlib/docs/devel/coding_guide.rst (rev 0) +++ trunk/matplotlib/docs/devel/coding_guide.rst 2008-05-24 20:49:31 UTC (rev 5253) @@ -0,0 +1,317 @@ +*************** +Version Control +*************** + +svn checkouts +============= + +Checking out everything in the trunk (matplotlib and toolkits):: + + svn co https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/trunk \ + matplotlib --username=youruser --password=yourpass + +Checking out the main source:: + + svn co https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/trunk/\ + matplotlib matplotlib --username=youruser --password=yourpass + +Branch checkouts, eg the maintenance branch:: + + svn co https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/branches/\ + v0_91_maint mplv0_91_maint + +Committing changes +================== + +When committing changes to matplotlib, there are a few things to bear +in mind. + +* if your changes are non-trivial, please make an entry in the + CHANGELOG +* if you change the API, please document it in API_CHANGES, and + consider posting to mpl-devel +* Are your changes python2.3 compatible? We are still trying to + support 2.3, so avoid 2.4 only features like decorators until we + remove 2.3 support +* Can you pass examples/backend_driver.py? This is our poor man's + unit test. +* If you have altered extension code, do you pass + unit/memleak_hawaii.py? +* if you have added new files or directories, or reorganized + existing ones, are the new files included in the match patterns in + MANIFEST.in. This file determines what goes into the src + distribution of the mpl build. +* Keep the maintenance branch and trunk in sync where it makes sense. + If there is a bug on both that needs fixing, use svnmerge.py to + keep them in sync. http://www.orcaware.com/svn/wiki/Svnmerge.py. The + basic procedure is: + + * install svnmerge.py in your PATH:: + + wget http://svn.collab.net/repos/svn/trunk/contrib/client-side/\ + svnmerge/svnmerge.py + + * get a svn copy of the maintenance branch and the trunk (see above) + * Michael advises making the change on the branch and committing + it. Make sure you svn upped on the trunk and have no local + modifications, and then from the svn trunk do:: + + > svnmerge.py merge -rNNN1,NNN2 + + where the NNN* are the revision numbers. Ranges arealso acceptable. + svnmergy.py automatically creates a file containing the commit messages, + so you are ready to make the commit:: + + > svn commit -F svnmerge-commit-message.txt + +*********** +Style Guide +*********** + +Importing and name spaces +========================= + +For numpy, use:: + + import numpy as np + a = np.array([1,2,3]) + +For masked arrays, use:: + + from numpy import ma + +(The earlier recommendation, 'import matplotlib.numerix.npyma as ma', +was needed temporarily during the development of the maskedarray +implementation as a separate package. As of numpy 1.1, it replaces the +old implementation. Note: "from numpy import ma" works with numpy < 1.1 +*and* with numpy >= 1.1. "import numpy.ma as ma" works *only* with +numpy >= 1.1, so for now we must not use it.) + +For matplotlib main module, use:: + + import matplotlib as mpl + mpl.rcParams['xtick.major.pad'] = 6 + +For matplotlib modules (or any other modules), use:: + + import matplotlib.cbook as cbook + + if cbook.iterable(z): + pass + +We prefer this over the equivalent 'from matplotlib import cbook' +because the latter is ambiguous whether cbook is a module or a +function to the new developer. The former makes it explcit that +you are importing a module or package. + +Naming, spacing, and formatting conventions +=========================================== + +In general, we want to hew as closely as possible to the standard +coding guidelines for python written by Guido in +http://www.python.org/dev/peps/pep-0008, though we do not do this +throughout. + +* functions and class methods: lower or lower_underscore_separated + +* attributes and variables: lower or lowerUpper + +* classes: Upper or MixedCase + +Personally, I prefer the shortest names that are still readable. + +Also, use an editor that does not put tabs in files. Four spaces +should be used for indentation everywhere and if there is a file with +tabs or more or less spaces it is a bug -- please fix it. + +Please avoid spurious invisible spaces at the ends of lines. +(Tell your editor to strip whitespace from line ends when saving +a file.) + +Keep docstrings uniformly indented as in the example below, with +nothing to the left of the triple quotes. The dedent() function +is needed to remove excess indentation only if something will be +interpolated into the docstring, again as in the example above. + +Limit line length to 80 characters. If a logical line needs to be +longer, use parentheses to break it; do not use an escaped +newline. It may be preferable to use a temporary variable +to replace a single long line with two shorter and more +readable lines. + +Please do not commit lines with trailing white space, as it causes +noise in svn diffs. If you are an emacs user, the following in your +.emacs will cause emacs to strip trailing white space on save for +python, C and C++:: + + ; and similarly for c++-mode-hook and c-mode-hook + (add-hook 'python-mode-hook + (lambda () + (add-hook 'write-file-functions 'delete-trailing-whitespace))) + +for older versions of emacs (emacs<22) you need to do:: + + (add-hook 'python-mode-hook + (lambda () + (add-hook 'local-write-file-hooks 'delete-trailing-whitespace))) + +Keyword argument processing +=========================== + +Matplotlib makes extensive use of ``**kwargs`` for pass through +customizations from one function to another. A typical example is in +pylab.text, The definition of the pylab text function is a simple +pass-through to axes.Axes.text:: + + # in pylab.py + def text(*args, **kwargs): + ret = gca().text(*args, **kwargs) + draw_if_interactive() + return ret + +axes.Axes.text in simplified form looks like this, ie it just passes +them on to text.Text.__init__:: + + # in axes.py + def text(self, x, y, s, fontdict=None, withdash=False, **kwargs): + t = Text(x=x, y=y, text=s, **kwargs) + +and Text.__init__ (again with liberties for illustration) just passes +them on to the artist.Artist.update method:: + + # in text.py + def __init__(self, x=0, y=0, text='', **kwargs): + Artist.__init__(self) + self.update(kwargs) + +'update' does the work looking for methods named like 'set_property' +if 'property' is a keyword argument. Ie, noone looks at the keywords, +they just get passed through the API to the artist constructor which +looks for suitably named methods and calls them with the value. + +As a general rule, the use of ``**kwargs`` should be reserved for +pass-through keyword arguments, as in the examaple above. If I intend +for all the keyword args to be used in some function and not passed +on, I just use the key/value keyword args in the function definition +rather than the ``**kwargs`` idiom. + +In some cases I want to consume some keys and pass through the others, +in which case I pop the ones I want to use locally and pass on the +rest, eg I pop scalex and scaley in Axes.plot and assume the rest are +Line2D keyword arguments. As an example of a pop, passthrough +usage, see Axes.plot:: + + # in axes.py + def plot(self, *args, **kwargs): + scalex = kwargs.pop('scalex', True) + scaley = kwargs.pop('scaley', True) + if not self._hold: self.cla() + lines = [] + for line in self._get_lines(*args, **kwargs): + self.add_line(line) + lines.append(line) + +The matplotlib.cbook function popd() is rendered +obsolete by the pop() dictionary method introduced in Python 2.3, +so it should not be used for new code. + +Note there is a use case when kwargs are meant to be used locally in +the function (not passed on), but you still need the ``**kwargs`` idiom. +That is when you want to use ``*args`` to allow variable numbers of +non-keyword args. In this case, python will not allow you to use +named keyword args after the ``*args`` usage, so you will be forced to use +``**kwargs``. An example is matplotlib.contour.ContourLabeler.clabel:: + + # in contour.py + def clabel(self, *args, **kwargs): + fontsize = kwargs.get('fontsize', None) + inline = kwargs.get('inline', 1) + self.fmt = kwargs.get('fmt', '%1.3f') + colors = kwargs.get('colors', None) + if len(args) == 0: + levels = self.levels + indices = range(len(self.levels)) + elif len(args) == 1: + ...etc... + +Documentation and Docstrings +============================ + +matplotlib uses artist instrospection of docstrings to support +properties. All properties that you want to support through setp and +getp should have a set_property and get_property method in the Artist +class. Yes, this is not ideal given python properties or enthought +traits, but it is a historical legacy for now. The setter methods use +the docstring with the ACCEPTS token to indicate the type of argument +the method accepts. Eg in matplotlib.lines.Line2D:: + + # in lines.py + def set_linestyle(self, linestyle): + """ + Set the linestyle of the line + + ACCEPTS: [ '-' | '--' | '-.' | ':' | 'steps' | 'None' | ' ' | '' ] + """ + +Since matplotlib uses a lot of pass through kwargs, eg in every +function that creates a line (plot, semilogx, semilogy, etc...), it +can be difficult for the new user to know which kwargs are supported. +I have developed a docstring interpolation scheme to support +documentation of every function that takes a ``**kwargs``. The +requirements are: + +1. single point of configuration so changes to the properties don't + require multiple docstring edits + +2. as automated as possible so that as properties change the docs + are updated automagically. + +I have added a matplotlib.artist.kwdocd and kwdoc() to faciliate this. +They combines python string interpolation in the docstring with the +matplotlib artist introspection facility that underlies setp and getp. +The kwdocd is a single dictionary that maps class name to a docstring +of kwargs. Here is an example from matplotlib.lines:: + + # in lines.py + artist.kwdocd['Line2D'] = artist.kwdoc(Line2D) + +Then in any function accepting Line2D passthrough kwargs, eg +matplotlib.axes.Axes.plot:: + + # in axes.py + def plot(self, *args, **kwargs): + """ + Some stuff omitted + + The kwargs are Line2D properties: + %(Line2D)s + + kwargs scalex and scaley, if defined, are passed on + to autoscale_view to determine whether the x and y axes are + autoscaled; default True. See Axes.autoscale_view for more + information + """ + pass + plot.__doc__ = cbook.dedent(plot.__doc__) % artist.kwdocd + +Note there is a problem for Artist __init__ methods, eg Patch.__init__ +which supports Patch kwargs, since the artist inspector cannot work +until the class is fully defined and we can't modify the +Patch.__init__.__doc__ docstring outside the class definition. I have +made some manual hacks in this case which violates the "single entry +point" requirement above; hopefully we'll find a more elegant solution +before too long + +******** +Licenses +******** + +Matplotlib only uses BSD compatible code. If you bring in code from +another project make sure it has a PSF, BSD, MIT or compatible +license. If not, you may consider contacting the author and asking +them to relicense it. GPL and LGPL code are not acceptible in the +main code base, though we are considering an alternative way of +distributing L/GPL code through an separate channel, possibly a +toolkit. If you include code, make sure you include a copy of that +code's license in the license directory if the code's license requires +you to distribute the license with it. \ No newline at end of file Added: trunk/matplotlib/docs/devel/documenting_mpl.rst =================================================================== --- trunk/matplotlib/docs/devel/documenting_mpl.rst (rev 0) +++ trunk/matplotlib/docs/devel/documenting_mpl.rst 2008-05-24 20:49:31 UTC (rev 5253) @@ -0,0 +1,76 @@ +********************** +Documenting Matplotlib +********************** + +The documentation for matplotlib is generated from ReStructured Text +using the Sphinx_ documentation generation tool. Sphinx-0.4 or later +is required. Currently this means we need to install from the svn +repository by doing:: + + svn co http://svn.python.org/projects/doctools/trunk sphinx + cd sphinx + python setup.py install + +.. _Sphinx: http://sphinx.pocoo.org/ + +The documentation sources are found in the doc/ directory in the trunk. +To build the users guid in html format, cd into doc/users_guide and do:: + + python make.py html + +you can also pass a ``latex`` flag to make.py to build a pdf, or pass no +arguments to build everything. The same procedure can be followed for +the sources in doc/api_reference. + +The actual ReStructured Text files are kept in doc/users_guide/source +and doc/api_reference/source. The main entry point is index.rst. +Additional files can be added by including their base file name +(dropping the .rst extension) in the table of contents. It is also +possible to include other documents through the use of an include +statement. For example, in the Developers Guide, index.rst lists +coding_guide, which automatically inserts coding_guide.rst. + +Mathematical expressions can be rendered as png images in html, and in +the usual way by latex. For example: + +``math:`sin(x_n^2)`` yields: :math:`sin(x_n^2)`, and:: + + .. math:: + + \int_{-\infty}^{\infty}\frac{e^{i\phi}}{1+x^2\frac{e^{i\phi}}{1+x^2}}`` + +yields: + +.. math:: + + \int_{-\infty}^{\infty}\frac{e^{i\phi}}{1+x^2\frac{e^{i\phi}}{1+x^2}} + +The output produced by Sphinx can be configured by editing the conf.py +files located in the documentation source directories. + +The Sphinx website contains plenty of documentation_ concerning ReST +markup and working with Sphinx in general. + +.. _documentation: http://sphinx.pocoo.org/contents.html + +Referring to mpl documents +========================== + +In the documentation, you may want to include to a document in the +matplotlib src, eg a license file, an image file from ``mpl-data``, or an +example. When you include these files, include them using a symbolic +link from the documentation parent directory. This way, if we +relocate the mpl documentation directory, all of the internal pointers +to files will not have to change, just the top level symlinks. For +example, In the top level doc directory we have symlinks pointing to +the mpl ``examples`` and ``mpl-data``:: + + home:~/mpl/doc2> ls -l mpl_* + mpl_data -> ../lib/matplotlib/mpl-data + mpl_examples -> ../examples + + +In the ``users`` subdirectory, if I want to refer to a file in the mpl-data directory, I use the symlink direcotry. For example, from ``customizing.rst``:: + + .. literalinclude:: ../mpl_data/matplotlibrc + Added: trunk/matplotlib/docs/devel/index.rst =================================================================== --- trunk/matplotlib/docs/devel/index.rst (rev 0) +++ trunk/matplotlib/docs/devel/index.rst 2008-05-24 20:49:31 UTC (rev 5253) @@ -0,0 +1,16 @@ +.. _developers_guide-index: + +################################### + The Matplotlib Developers's Guide +################################### + +:Release: |version| +:Date: |today| + +Introduction to developer's guide here **TODO**. + +.. toctree:: + + coding_guide.rst + documenting_mpl.rst + add_new_projection.rst Added: trunk/matplotlib/docs/index.rst =================================================================== --- trunk/matplotlib/docs/index.rst (rev 0) +++ trunk/matplotlib/docs/index.rst 2008-05-24 20:49:31 UTC (rev 5253) @@ -0,0 +1,23 @@ +.. matplotlib documentation master file, created by sphinx-quickstart on Sat May 24 15:37:00 2008. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +Welcome to matplotlib's documentation! +====================================== + +Contents: + +.. toctree:: + :maxdepth: 2 + + users/index.rst + devel/index.rst + api/index.rst + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` + Added: trunk/matplotlib/docs/make.py =================================================================== --- trunk/matplotlib/docs/make.py (rev 0) +++ trunk/matplotlib/docs/make.py 2008-05-24 20:49:31 UTC (rev 5253) @@ -0,0 +1,68 @@ +#!/usr/bin/env python +import fileinput +import glob +import os +import shutil +import sys + +def check_build(): + build_dirs = ['build', 'build/doctrees', 'build/html', 'build/latex', + '_static', '_templates'] + for d in build_dirs: + try: + os.mkdir(d) + except OSError: + pass + +def figs(): + os.system('cd users/figures/ && python make.py') + +def html(): + check_build() + os.system('sphinx-build -b html -d build/doctrees . build/html') + +def latex(): + if sys.platform != 'win32': + # LaTeX format. + os.system('sphinx-build -b latex -d build/doctrees . build/latex') + + # Produce pdf. + os.chdir('build/latex') + + # Copying the makefile produced by sphinx... + os.system('pdflatex Matplotlib_Users_Guide.tex') + os.system('pdflatex Matplotlib_Users_Guide.tex') + os.system('makeindex -s python.ist Matplotlib_Users_Guide.idx') + os.system('makeindex -s python.ist modMatplotlib_Users_Guide.idx') + os.system('pdflatex Matplotlib_Users_Guide.tex') + + os.chdir('../..') + else: + print 'latex build has not been tested on windows' + +def clean(): + shutil.rmtree('build') + +def all(): + figs() + html() + latex() + + +funcd = {'figs':figs, + 'html':html, + 'latex':latex, + 'clean':clean, + 'all':all, + } + + +if len(sys.argv)>1: + for arg in sys.argv[1:]: + func = funcd.get(arg) + if func is None: + raise SystemExit('Do not know how to handle %s; valid args are'%( + arg, funcd.keys())) + func() +else: + all() Property changes on: trunk/matplotlib/docs/make.py ___________________________________________________________________ Name: svn:executable + * Added: trunk/matplotlib/docs/mpl_data =================================================================== --- trunk/matplotlib/docs/mpl_data (rev 0) +++ trunk/matplotlib/docs/mpl_data 2008-05-24 20:49:31 UTC (rev 5253) @@ -0,0 +1 @@ +link ../lib/matplotlib/mpl-data/ \ No newline at end of file Property changes on: trunk/matplotlib/docs/mpl_data ___________________________________________________________________ Name: svn:special + * Added: trunk/matplotlib/docs/mpl_examples =================================================================== --- trunk/matplotlib/docs/mpl_examples (rev 0) +++ trunk/matplotlib/docs/mpl_examples 2008-05-24 20:49:31 UTC (rev 5253) @@ -0,0 +1 @@ +link ../examples/ \ No newline at end of file Property changes on: trunk/matplotlib/docs/mpl_examples ___________________________________________________________________ Name: svn:special + * Added: trunk/matplotlib/docs/sphinxext/ipython_console_highlighting.py =================================================================== --- trunk/matplotlib/docs/sphinxext/ipython_console_highlighting.py (rev 0) +++ trunk/matplotlib/docs/sphinxext/ipython_console_highlighting.py 2008-05-24 20:49:31 UTC (rev 5253) @@ -0,0 +1,75 @@ +from pygments.lexer import Lexer, do_insertions +from pygments.lexers.agile import PythonConsoleLexer, PythonLexer, \ + PythonTracebackLexer +from pygments.token import Comment, Generic +from sphinx import highlighting +import re + +line_re = re.compile('.*?\n') + +class IPythonConsoleLexer(Lexer): + """ + For IPython console output or doctests, such as: + + Tracebacks are not currently supported. + + .. sourcecode:: pycon + + In [1]: a = 'foo' + + In [2]: a + Out[2]: 'foo' + + In [3]: print a + foo + + In [4]: 1 / 0 + """ + name = 'IPython console session' + aliases = ['ipython'] + mimetypes = ['text/x-ipython-console'] + input_prompt = re.compile("(In \[[0-9]+\]: )|( \.\.\.+:)") + output_prompt = re.compile("(Out\[[0-9]+\]: )|( \.\.\.+:)") + continue_prompt = re.compile(" \.\.\.+:") + tb_start = re.compile("\-+") + + def get_tokens_unprocessed(self, text): + pylexer = PythonLexer(**self.options) + tblexer = PythonTracebackLexer(**self.options) + + curcode = '' + insertions = [] + for match in line_re.finditer(text): + line = match.group() + input_prompt = self.input_prompt.match(line) + continue_prompt = self.continue_prompt.match(line.rstrip()) + output_prompt = self.output_prompt.match(line) + if line.startswith("#"): + insertions.append((len(curcode), + [(0, Comment, line)])) + elif input_prompt is not None: + insertions.append((len(curcode), + [(0, Generic.Prompt, input_prompt.group())])) + curcode += line[input_prompt.end():] + elif continue_prompt is not None: + insertions.append((len(curcode), + [(0, Generic.Prompt, continue_prompt.group())])) + curcode += line[continue_prompt.end():] + elif output_prompt is not None: + insertions.append((len(curcode), + [(0, Generic.Output, output_prompt.group())])) + curcode += line[output_prompt.end():] + else: + if curcode: + for item in do_insertions(insertions, + pylexer.get_tokens_unprocessed(curcode)): + yield item + curcode = '' + insertions = [] + yield match.start(), Generic.Output, line + if curcode: + for item in do_insertions(insertions, + pylexer.get_tokens_unprocessed(curcode)): + yield item + +highlighting.lexers['ipython'] = IPythonConsoleLexer() Added: trunk/matplotlib/docs/sphinxext/mathml.py =================================================================== --- trunk/matplotlib/docs/sphinxext/mathml.py (rev 0) +++ trunk/matplotlib/docs/sphinxext/mathml.py 2008-05-24 20:49:31 UTC (rev 5253) @@ -0,0 +1,552 @@ +from docutils import nodes +from docutils.writers.html4css1 import HTMLTranslator +from sphinx.latexwriter import LaTeXTranslator + +# Define LaTeX math node: +class latex_math(nodes.General, nodes.Element): + pass + +def math_role(role, rawtext, text, lineno, inliner, + options={}, content=[]): + i = rawtext.find('`') + latex = rawtext[i+1:-1] + try: + mathml_tree = parse_latex_math(latex, inline=True) + except SyntaxError, msg: + msg = inliner.reporter.error(msg, line=lineno) + prb = inliner.problematic(rawtext, rawtext, msg) + return [prb], [msg] + node = latex_math(rawtext) + node['latex'] = latex + node['mathml_tree'] = mathml_tree + return [node], [] + + +try: + from docutils.parsers.rst import Directive +except ImportError: + # Register directive the old way: + from docutils.parsers.rst.directives import _directives + def math_directive(name, arguments, options, content, lineno, + content_offset, block_text, state, state_machine): + latex = ''.join(content) + try: + mathml_tree = parse_latex_math(latex, inline=False) + except SyntaxError, msg: + error = state_machine.reporter.error( + msg, nodes.literal_block(block_text, block_text), line=lineno) + return [error] + node = latex_math(block_text) + node['latex'] = latex + node['mathml_tree'] = mathml_tree + return [node] + math_directive.arguments = None + math_directive.options = {} + math_directive.content = 1 + _directives['math'] = math_directive +else: + class math_directive(Directive): + has_content = True + def run(self): + latex = ' '.join(self.content) + try: + mathml_tree = parse_latex_math(latex, inline=False) + except SyntaxError, msg: + error = self.state_machine.reporter.error( + msg, nodes.literal_block(self.block_text, self.block_text), + line=self.lineno) + return [error] + node = latex_math(self.block_text) + node['latex'] = latex + node['mathml_tree'] = mathml_tree + return [node] + from docutils.parsers.rst import directives + directives.register_directive('math', math_directive) + +def setup(app): + app.add_node(latex_math) + app.add_role('math', math_role) + + # Add visit/depart methods to HTML-Translator: + def visit_latex_math_html(self, node): + mathml = ''.join(node['mathml_tree'].xml()) + self.body.append(mathml) + def depart_latex_math_html(self, node): + pass + HTMLTranslator.visit_latex_math = visit_latex_math_html + HTMLTranslator.depart_latex_math = depart_latex_math_html + + # Add visit/depart methods to LaTeX-Translator: + def visit_latex_math_latex(self, node): + inline = isinstance(node.parent, nodes.TextElement) + if inline: + self.body.append('$%s$' % node['latex']) + else: + self.body.extend(['\\begin{equation}', + node['latex'], + '\\end{equation}']) + def depart_latex_math_latex(self, node): + pass + LaTeXTranslator.visit_latex_math = visit_latex_math_latex + LaTeXTranslator.depart_latex_math = depart_latex_math_latex + + +# LaTeX to MathML translation stuff: +class math: + """Base class for MathML elements.""" + + nchildren = 1000000 + """Required number of children""" + + def __init__(self, children=None, inline=None): + """math([children]) -> MathML element + + children can be one child or a list of children.""" + + self.children = [] + if children is not None: + if type(children) is list: + for child in children: + self.append(child) + else: + # Only one child: + self.append(children) + + if inline is not None: + self.inline = inline + + def __repr__(self): + if hasattr(self, 'children'): + return self.__class__.__name__ + '(%s)' % \ + ','.join([repr(child) for child in self.children]) + else: + return self.__class__.__name__ + + def full(self): + """Room for more children?""" + + return len(self.children) >= self.nchildren + + def append(self, child): + """append(child) -> element + + Appends child and returns self if self is not full or first + non-full parent.""" + + assert not self.full() + self.children.append(child) + child.parent = self + node = self + while node.full(): + node = node.parent + return node + + def delete_child(self): + """delete_child() -> child + + Delete last child and return it.""" + + child = self.children[-1] + del self.children[-1] + return child + + def close(self): + """close() -> parent + + Close element and return first non-full element.""" + + parent = self.parent + while parent.full(): + parent = parent.parent + return parent + + def xml(self): + """xml() -> xml-string""" + + return self.xml_start() + self.xml_body() + self.xml_end() + + def xml_start(self): + if not hasattr(self, 'inline'): + return ['<%s>' % self.__class__.__name__] + xmlns = 'http://www.w3.org/1998/Math/MathML' + if self.inline: + return ['<math xmlns="%s">' % xmlns] + else: + return ['<math xmlns="%s" mode="display">' % xmlns] + + def xml_end(self): + return ['</%s>' % self.__class__.__name__] + + def xml_body(self): + xml = [] + for child in self.children: + xml.extend(child.xml()) + return xml + +class mrow(math): pass +class mtable(math): pass +class mtr(mrow): pass +class mtd(mrow): pass + +class mx(math): + """Base class for mo, mi, and mn""" + + nchildren = 0 + def __init__(self, data): + self.data = data + + def xml_body(self): + return [self.data] + +class mo(mx): + translation = {'<': '<', '>': '>'} + def xml_body(self): + return [self.translation.get(self.data, self.data)] + +class mi(mx): pass +class mn(mx): pass + +class msub(math): + nchildren = 2 + +class msup(math): + nchildren = 2 + +class msqrt(math): + nchildren = 1 + +class mroot(math): + nchildren = 2 + +class mfrac(math): + nchildren = 2 + +class msubsup(math): + nchildren = 3 + def __init__(self, children=None, reversed=False): + self.reversed = reversed + math.__init__(self, children) + + def xml(self): + if self.reversed: +## self.children[1:3] = self.children[2:0:-1] + self.children[1:3] = [self.children[2], self.children[1]] + self.reversed = False + return math.xml(self) + +class mfenced(math): + translation = {'\\{': '{', '\\langle': u'\u2329', + '\\}': '}', '\\rangle': u'\u232A', + '.': ''} + def __init__(self, par): + self.openpar = par + math.__init__(self) + + def xml_start(self): + open = self.translation.get(self.openpar, self.openpar) + close = self.translation.get(self.closepar, self.closepar) + return ['<mfenced open="%s" close="%s">' % (open, close)] + +class mspace(math): + nchildren = 0 + +class mstyle(math): + def __init__(self, children=None, nchildren=None, **kwargs): + if nchildren is not None: + self.nchildren = nchildren + math.__init__(self, children) + self.attrs = kwargs + + def xml_start(self): + return ['<mstyle '] + ['%s="%s"' % item + for item in self.attrs.items()] + ['>'] + +class mover(math): + nchildren = 2 + def __init__(self, children=None, reversed=False): + self.reversed = reversed + math.__init__(self, children) + + def xml(self): + if self.reversed: + self.children.reverse() + self.reversed = False + return math.xml(self) + +class munder(math): + nchildren = 2 + +class munderover(math): + nchildren = 3 + def __init__(self, children=None): + math.__init__(self, children) + +class mtext(math): + nchildren = 0 + def __init__(self, text): + self.text = text + + def xml_body(self): + return [self.text] + + +over = {'tilde': '~', + 'hat': '^', + 'bar': '_', + 'vec': u'\u2192'} + +Greek = { + # Upper case greek letters: + 'Phi': u'\u03a6', 'Xi': u'\u039e', 'Sigma': u'\u03a3', 'Psi': u'\u03a8', 'Delta': u'\u0394', 'Theta': u'\u0398', 'Upsilon': u'\u03d2', 'Pi': u'\u03a0', 'Omega': u'\u03a9', 'Gamma': u'\u0393', 'Lambda': u'\u039b'} +greek = { + # Lower case greek letters: + 'tau': u'\u03c4', 'phi': u'\u03d5', 'xi': u'\u03be', 'iota': u'\u03b9', 'epsilon': u'\u03f5', 'varrho': u'\u03f1', 'varsigma': u'\u03c2', 'beta': u'\u03b2', 'psi': u'\u03c8', 'rho': u'\u03c1', 'delta': u'\u03b4', 'alpha': u'\u03b1', 'zeta': u'\u03b6', 'omega': u'\u03c9', 'varepsilon': u'\u03b5', 'kappa': u'\u03ba', 'vartheta': u'\u03d1', 'chi': u'\u03c7', 'upsilon': u'\u03c5', 'sigma': u'\u03c3', 'varphi': u'\u03c6', 'varpi': u'\u03d6', 'mu': u'\u03bc', 'eta': u'\u03b7', 'theta': u'\u03b8', 'pi': u'\u03c0', 'varkappa': u'\u03f0', 'nu': u'\u03bd', 'gamma': u'\u03b3', 'lambda': u'\u03bb'} + +special = { + # Binary operation symbols: + 'wedge': u'\u2227', 'diamond': u'\u22c4', 'star': u'\u22c6', 'amalg': u'\u2a3f', 'ast': u'\u2217', 'odot': u'\u2299', 'triangleleft': u'\u25c1', 'bigtriangleup': u'\u25b3', 'ominus': u'\u2296', 'ddagger': u'\u2021', 'wr': u'\u2240', 'otimes': u'\u2297', 'sqcup': u'\u2294', 'oplus': u'\u2295', 'bigcirc': u'\u25cb', 'oslash': u'\u2298', 'sqcap': u'\u2293', 'bullet': u'\u2219', 'cup': u'\u222a', 'cdot': u'\u22c5', 'cap': u'\u2229', 'bigtriangledown': u'\u25bd', 'times': u'\xd7', 'setminus': u'\u2216', 'circ': u'\u2218', 'vee': u'\u2228', 'uplus': u'\u228e', 'mp': u'\u2213', 'dagger': u'\u2020', 'triangleright': u'\u25b7', 'div': u'\xf7', 'pm': u'\xb1', + # Relation symbols: + 'subset': u'\u2282', 'propto': u'\u221d', 'geq': u'\u2265', 'ge': u'\u2265', 'sqsubset': u'\u228f', 'Join': u'\u2a1d', 'frown': u'\u2322', 'models': u'\u22a7', 'supset': u'\u2283', 'in': u'\u2208', 'doteq': u'\u2250', 'dashv': u'\u22a3', 'gg': u'\u226b', 'leq': u'\u2264', 'succ': u'\u227b', 'vdash': u'\u22a2', 'cong': u'\u2245', 'simeq': u'\u2243', 'subseteq': u'\u2286', 'parallel': u'\u2225', 'equiv': u'\u2261', 'ni': u'\u220b', 'le': u'\u2264', 'approx': u'\u2248', 'precsim': u'\u227e', 'sqsupset': u'\u2290', 'll': u'\u226a', 'sqsupseteq': u'\u2292', 'mid': u'\u2223', 'prec': u'\u227a', 'succsim': u'\u227f', 'bowtie': u'\u22c8', 'perp': u'\u27c2', 'sqsubseteq': u'\u2291', 'asymp': u'\u224d', 'smile': u'\u2323', 'supseteq': u'\u2287', 'sim': u'\u223c', 'neq': u'\u2260', + # Arrow symbols: + 'searrow': u'\u2198', 'updownarrow': u'\u2195', 'Uparrow': u'\u21d1', 'longleftrightarrow': u'\u27f7', 'Leftarrow': u'\u21d0', 'longmapsto': u'\u27fc', 'Longleftarrow': u'\u27f8', 'nearrow': u'\u2197', 'hookleftarrow': u'\u21a9', 'downarrow': u'\u2193', 'Leftrightarrow': u'\u21d4', 'longrightarrow': u'\u27f6', 'rightharpoondown': u'\u21c1', 'longleftarrow': u'\u27f5', 'rightarrow': u'\u2192', 'Updownarrow': u'\u21d5', 'rightharpoonup': u'\u21c0', 'Longleftrightarrow': u'\u27fa', 'leftarrow': u'\u2190', 'mapsto': u'\u21a6', 'nwarrow': u'\u2196', 'uparrow': u'\u2191', 'leftharpoonup': u'\u21bc', 'leftharpoondown': u'\u21bd', 'Downarrow': u'\u21d3', 'leftrightarrow': u'\u2194', 'Longrightarrow': u'\u27f9', 'swarrow': u'\u2199', 'hookrightarrow': u'\u21aa', 'Rightarrow': u'\u21d2', + # Miscellaneous symbols: + 'infty': u'\u221e', 'surd': u'\u221a', 'partial': u'\u2202', 'ddots': u'\u22f1', 'exists': u'\u2203', 'flat': u'\u266d', 'diamondsuit': u'\u2662', 'wp': u'\u2118', 'spadesuit': u'\u2660', 'Re': u'\u211c', 'vdots': u'\u22ee', 'aleph': u'\u2135', 'clubsuit': u'\u2663', 'sharp': u'\u266f', 'angle': u'\u2220', 'prime': u'\u2032', 'natural': u'\u266e', 'ell': u'\u2113', 'neg': u'\xac', 'top': u'\u22a4', 'nabla': u'\u2207', 'bot': u'\u22a5', 'heartsuit': u'\u2661', 'cdots': u'\u22ef', 'Im': u'\u2111', 'forall': u'\u2200', 'imath': u'\u0131', 'hbar': u'\u210f', 'emptyset': u'\u2205', + # Variable-sized symbols: + 'bigotimes': u'\u2a02', 'coprod': u'\u2210', 'int': u'\u222b', 'sum': u'\u2211', 'bigodot': u'\u2a00', 'bigcup': u'\u22c3', 'biguplus': u'\u2a04', 'bigcap': u'\u22c2', 'bigoplus': u'\u2a01', 'oint': u'\u222e', 'bigvee': u'\u22c1', 'bigwedge': u'\u22c0', 'prod': u'\u220f', + # Braces: + 'langle': u'\u2329', 'rangle': u'\u232A'} + +sumintprod = ''.join([special[symbol] for symbol in + ['sum', 'int', 'oint', 'prod']]) + +functions = ['arccos', 'arcsin', 'arctan', 'arg', 'cos', 'cosh', + 'cot', 'coth', 'csc', 'deg', 'det', 'dim', + 'exp', 'gcd', 'hom', 'inf', 'ker', 'lg', + 'lim', 'liminf', 'limsup', 'ln', 'log', 'max', + 'min', 'Pr', 'sec', 'sin', 'sinh', 'sup', + 'tan', 'tanh', + 'injlim', 'varinjlim', 'varlimsup', + 'projlim', 'varliminf', 'varprojlim'] + + +def parse_latex_math(string, inline=True): + """parse_latex_math(string [,inline]) -> MathML-tree + + Returns a MathML-tree parsed from string. inline=True is for + inline math and inline=False is for displayed math. + + tree is the whole tree and node is the current element.""" + + # Normalize white-space: + string = ' '.join(string.split()) + + if inline: + node = mrow() + tree = math(node, inline=True) + else: + node = mtd() + tree = math(mtable(mtr(node)), inline=False) + + while len(string) > 0: + n = len(string) + c = string[0] + skip = 1 # number of characters consumed + if n > 1: + c2 = string[1] + else: + c2 = '' +## print n, string, c, c2, node.__class__.__name__ + if c == ' ': + pass + elif c == '\\': + if c2 in '{}': + node = node.append(mo(c2)) + skip = 2 + elif c2 == ' ': + node = node.append(mspace()) + skip = 2 + elif c2.isalpha(): + # We have a LaTeX-name: + i = 2 + while i < n and string[i].isalpha(): + i += 1 + name = string[1:i] + node, skip = handle_keyword(name, node, string[i:]) + skip += i + elif c2 == '\\': + # End of a row: + entry = mtd() + row = mtr(entry) + node.close().close().append(row) + node = entry + skip = 2 + else: + raise SyntaxError('Syntax error: "%s%s"' % (c, c2)) + elif c.isalpha(): + node = node.append(mi(c)) + elif c.isdigit(): + node = node.append(mn(c)) + elif c in "+-/()[]|=<>,.!'": + node = node.append(mo(c)) + elif c == '_': + child = node.delete_child() + if isinstance(child, msup): + sub = msubsup(child.children, reversed=True) + elif isinstance(child, mo) and child.data in sumintprod: + sub = munder(child) + else: + sub = msub(child) + node.append(sub) + node = sub + elif c == '^': + child = node.delete_child() + if isinstance(child, msub): + sup = msubsup(child.children) + elif isinstance(child, mo) and child.data in sumintprod: + sup = mover(child) + elif (isinstance(child, munder) and + child.children[0].data in sumintprod): + sup = munderover(child.children) + else: + sup = msup(child) + node.append(sup) + node = sup + elif c == '{': + row = mrow() + node.append(row) + node = row + elif c == '}': + node = node.close() + elif c == '&': + entry = mtd() + node.close().append(entry) + node = entry + else: + raise SyntaxError('Illegal character: "%s"' % c) + string = string[skip:] + return tree + + +mathbb = {'A': u'\U0001D538', + 'B': u'\U0001D539', + 'C': u'\u2102', + 'D': u'\U0001D53B', + 'E': u'\U0001D53C', + 'F': u'\U0001D53D', + 'G': u'\U0001D53E', + 'H': u'\u210D', + 'I': u'\U0001D540', + 'J': u'\U0001D541', + 'K': u'\U0001D542', + 'L': u'\U0001D543', + 'M': u'\U0001D544', + 'N': u'\u2115', + 'O': u'\U0001D546', + 'P': u'\u2119', + 'Q': u'\u211A', + 'R': u'\u211D', + 'S': u'\U0001D54A', + 'T': u'\U0001D54B', + 'U': u'\U0001D54C', + 'V': u'\U0001D54D', + 'W': u'\U0001D54E', + 'X': u'\U0001D54F', + 'Y': u'\U0001D550', + 'Z': u'\u2124'} + +negatables = {'=': u'\u2260', + '\in': u'\u2209', + '\equiv': u'\u2262'} + + +def handle_keyword(name, node, string): + skip = 0 + if len(string) > 0 and string[0] == ' ': + string = string[1:] + skip = 1 + if name == 'begin': + if not string.startswith('{matrix}'): + raise SyntaxError('Expected "\begin{matrix}"!') + skip += 8 + entry = mtd() + table = mtable(mtr(entry)) + node.append(table) + node = entry + elif name == 'end': + if not string.startswith('{matrix}'): + raise SyntaxError('Expected "\end{matrix}"!') + skip += 8 + node = node.close().close().close() + elif name == 'text': + if string[0] != '{': + raise SyntaxError('Expected "\text{...}"!') + i = string.find('}') + if i == -1: + raise SyntaxError('Expected "\text{...}"!') + node = node.append(mtext(string[1:i])) + skip += i + 1 + elif name == 'sqrt': + sqrt = msqrt() + node.append(sqrt) + node = sqrt + elif name == 'frac': + frac = mfrac() + node.append(frac) + node = frac + elif name == 'left': + for par in ['(', '[', '|', '\\{', '\\langle', '.']: + if string.startswith(par): + break + else: + raise SyntaxError('Missing left-brace!') + fenced = mfenced(par) + node.append(fenced) + row = mrow() + fenced.append(row) + node = row + skip += len(par) + elif name == 'right': + for par in [')', ']', '|', '\\}', '\\rangle', '.']: + if string.startswith(par): + break + else: + raise SyntaxError('Missing right-brace!') + node = node.close() + node.closepar = par + node = node.close() + skip += len(par) + elif name == 'not': + for operator in negatables: + if string.startswith(operator): + break + else: + raise SyntaxError('Expected something to negate: "\\not ..."!') + node = node.append(mo(negatables[operator])) + skip += len(operator) + elif name == 'mathbf': + style = mstyle(nchildren=1, fontweight='bold') + node.append(style) + node = style + elif name == 'mathbb': + if string[0] != '{' or not string[1].isupper() or string[2] != '}': + raise SyntaxError('Expected something like "\mathbb{A}"!') + node = node.append(mi(mathbb[string[1]])) + skip += 3 + elif name in greek: + node = node.append(mi(greek[name])) + elif name in Greek: + node = node.append(mo(Greek[name])) + elif name in special: + node = node.append(mo(special[name])) + elif name in functions: + node = node.append(mo(name)) + else: + chr = over.get(name) + if chr is not None: + ovr = mover(mo(chr), reversed=True) + node.append(ovr) + node = ovr + else: + raise SyntaxError('Unknown LaTeX command: ' + name) + + return node, skip Added: trunk/matplotlib/docs/sphinxext/mathpng.py =================================================================== --- trunk/matplotlib/docs/sphinxext/mathpng.py (rev 0) +++ trunk/matplotlib/docs/sphinxext/mathpng.py 2008-05-24 20:49:31 UTC (rev 5253) @@ -0,0 +1,111 @@ +import os +try: + from hashlib import md5 +except ImportError: + from md5 import md5 + +from docutils import nodes +from docutils.writers.html4css1 import HTMLTranslator +from sphinx.latexwriter import LaTeXTranslator + +# Define LaTeX math node: +class latex_math(nodes.General, nodes.Element): + pass + +def math_role(role, rawtext, text, lineno, inliner, + options={}, content=[]): + i = rawtext.find('`') + latex = rawtext[i+1:-1] + node = latex_math(rawtext) + node['latex'] = latex + return [node], [] + + +try: + from docutils.parsers.rst import Directive +except ImportError: + # Register directive the old way: + from docutils.parsers.rst.directives import _directives + def math_directive(name, arguments, options, content, lineno, + content_offset, block_text, state, state_machine): + latex = ''.join(content) + node = latex_math(block_text) + node['latex'] = latex + return [node] + math_directive.arguments = None + math_directive.options = {} + math_directive.content = 1 + _directives['math'] = math_directive +else: + class math_directive(Directive): + has_content = True + def run(self): + latex = ' '.join(self.content) + node = latex_math(self.block_text) + node['latex'] = latex + return [node] + from docutils.parsers.rst import directives + directives.register_directive('math', math_directive) + +def setup(app): + app.add_node(latex_math) + app.add_role('math', math_role) + + # Add visit/depart methods to HTML-Translator: + def visit_latex_math_html(self, node): + source = self.document.attributes['source'] + self.body.append(latex2html(node, source)) + def depart_latex_math_html(self, node): + pass + HTMLTranslator.visit_latex_math = visit_latex_math_html + HTMLTranslator.depart_latex_math = depart_latex_math_html + + # Add visit/depart methods to LaTeX-Translator: + def visit_latex_math_latex(self, node): + inline = isinstance(node.parent, nodes.TextElement) + if inline: + self.body.append('$%s$' % node['latex']) + else: + self.body.extend(['\\begin{equation}', + node['latex'], + '\\end{equation}']) + def depart_latex_math_latex(self, node): + pass + LaTeXTranslator.visit_latex_math = visit_latex_math_latex + LaTeXTranslator.depart_latex_math = depart_latex_math_latex + +from os.path import isfile +# LaTeX to HTML translation stuff: +def latex2html(node, source): + inline = isinstance(node.parent, nodes.TextElement) + latex = node['latex'] + print latex + name = 'math-' + md5(latex).hexdigest()[-10:] + if not isfile('_static/%s.png' % name): + f = open('math.tex', 'w') + f.write(r... [truncated message content] |
From: <jd...@us...> - 2008-05-25 20:58:10
|
Revision: 5265 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5265&view=rev Author: jdh2358 Date: 2008-05-25 13:58:06 -0700 (Sun, 25 May 2008) Log Message: ----------- updated default dir names for svn checkouts Modified Paths: -------------- trunk/matplotlib/docs/devel/coding_guide.rst trunk/matplotlib/examples/api/logo2.py Removed Paths: ------------- trunk/matplotlib/CODING_GUIDE Deleted: trunk/matplotlib/CODING_GUIDE =================================================================== --- trunk/matplotlib/CODING_GUIDE 2008-05-25 16:57:31 UTC (rev 5264) +++ trunk/matplotlib/CODING_GUIDE 2008-05-25 20:58:06 UTC (rev 5265) @@ -1,320 +0,0 @@ -= The matplotlib developer's guide = - -This is meant to be a guide to developers on the mpl coding practices -and standards. Please edit and extend this document. - -== svn checkouts == - -# checking out everything (toolkits, user's guide, htdocs, etc..) -svn co https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/trunk matplotlib --username=youruser --password=yourpass - - -# checking out the main src -svn co https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/trunk/matplotlib matplotlib --username=youruser --password=yourpass - -# branch checkouts, eg the transforms branch -svn co https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/branches/transforms transbranch - -== Committing changes == - -When committing changes to matplotlib, there are a few things to bear -in mind. - - * if your changes are non-trivial, please make an entry in the - CHANGELOG - - * if you change the API, please document it in API_CHANGES, and - consider posting to mpl-devel - - * Are your changes python2.3 compatible? We are still trying to - support 2.3, so avoid 2.4 only features like decorators until we - remove 2.3 support - - * Can you pass examples/backend_driver.py? This is our poor man's - unit test. - - * If you have altered extension code, do you pass - unit/memleak_hawaii.py? - - * if you have added new files or directories, or reorganized - existing ones, are the new files included in the match patterns in - MANIFEST.in. This file determines what goes into the src - distribution of the mpl build. - - * Keep the maintenance branch and trunk in sync where it makes sense. - If there is a bug on both that needs fixing, use svnmerge.py to - keep them in sync. http://www.orcaware.com/svn/wiki/Svnmerge.py. The - basic procedure is: - - - install svnmerge.py in your PATH: - wget http://svn.collab.net/repos/svn/trunk/contrib/client-side/svnmerge/svnmerge.py - - - get a svn copy of the branch (svn co - https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/branches/v0_91_maint) - and the trunk (svn co - https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/trunk/matplotlib) - - - Michael advises making the change on the branch and committing - it. Make sure you svn upped on the trunk and have no local - modifications, and then from the svn trunk do - - # where the NNN are the revision numbers. ranges also acceptable - > svnmerge.py merge -rNNN1,NNN2 - - # this file is automatically created by the merge command - > svn commit -F svnmerge-commit-message.txt - -== Importing and name spaces == - -For numpy, use: - - - import numpy as np - a = np.array([1,2,3]) - - -For masked arrays, use: - from numpy import ma - - (The earlier recommendation, 'import matplotlib.numerix.npyma as ma', - was needed temporarily during the development of the maskedarray - implementation as a separate package. As of numpy 1.05, it - replaces the old implementation. - Note: "from numpy import ma" works with numpy < 1.05 *and* with - numpy >= 1.05. "import numpy.ma as ma" works *only* with - numpy >= 1.05, so for now we must not use it.) - -For matplotlib main module, use: - - import matplotlib as mpl - mpl.rcParams['xtick.major.pad'] = 6 - -For matplotlib modules (or any other modules), use: - - import matplotlib.cbook as cbook - - if cbook.iterable(z): - pass - - We prefer this over the equivalent 'from matplotlib import cbook' - because the latter is ambiguous whether cbook is a module or a - function to the new developer. The former makes it explcit that - you are importing a module or package. - -== Naming, spacing, and formatting conventions == - -In general, we want to hew as closely as possible to the standard -coding guidelines for python written by Guido in -http://www.python.org/dev/peps/pep-0008, though we do not do this -throughout. - - functions and class methods : lower or lower_underscore_separated - - attributes and variables : lower or lowerUpper - - classes : Upper or MixedCase - -Personally, I prefer the shortest names that are still readable. - -Also, use an editor that does not put tabs in files. Four spaces -should be used for indentation everywhere and if there is a file with -tabs or more or less spaces it is a bug -- please fix it. - -Please avoid spurious invisible spaces at the ends of lines. -(Tell your editor to strip whitespace from line ends when saving -a file.) - -Keep docstrings uniformly indented as in the example below, with -nothing to the left of the triple quotes. The dedent() function -is needed to remove excess indentation only if something will be -interpolated into the docstring, again as in the example above. - -Limit line length to 80 characters. If a logical line needs to be -longer, use parentheses to break it; do not use an escaped -newline. It may be preferable to use a temporary variable -to replace a single long line with two shorter and more -readable lines. - -Please do not commit lines with trailing white space, as it causes -noise in svn diffs. If you are an emacs user, the following in your -.emacs will cause emacs to strip trailing white space on save for -python, C and C++ - - -; and similarly for c++-mode-hook and c-mode-hook -(add-hook 'python-mode-hook - (lambda () - (add-hook 'write-file-functions 'delete-trailing-whitespace))) - - - -for older versions of emacs (emacs<22) you need to do - -(add-hook 'python-mode-hook - (lambda () - (add-hook 'local-write-file-hooks 'delete-trailing-whitespace))) - - - - -== Licenses == - -matplotlib only uses BSD compatible code. If you bring in code from -another project make sure it has a PSF, BSD, MIT or compatible -license. If not, you may consider contacting the author and asking -them to relicense it. GPL and LGPL code are not acceptible in the -main code base, though we are considering an alternative way of -distributing L/GPL code through an separate channel, possibly a -toolkit. If you include code, make sure you include a copy of that -code's license in the license directory if the code's license requires -you to distribute the license with it. - - -== Keyword argument processing == - -Matplotlib makes extensive use of **kwargs for pass through -customizations from one function to another. A typical example is in -pylab.text, The definition of the pylab text function is a simple -pass-through to axes.Axes.text - - # in pylab.py - def text(*args, **kwargs): - ret = gca().text(*args, **kwargs) - draw_if_interactive() - return ret - - -axes.Axes.text in simplified form looks like this, ie it just passes -them on to text.Text.__init__ - # in axes.py - def text(self, x, y, s, fontdict=None, withdash=False, **kwargs): - t = Text(x=x, y=y, text=s, **kwargs) - - -and Text.__init__ (again with liberties for illustration) just passes -them on to the artist.Artist.update method - - # in text.py - def __init__(self, x=0, y=0, text='', **kwargs): - Artist.__init__(self) - self.update(kwargs) - -'update' does the work looking for methods named like 'set_property' -if 'property' is a keyword argument. Ie, noone looks at the keywords, -they just get passed through the API to the artist constructor which -looks for suitably named methods and calls them with the value. - -As a general rule, the use of **kwargs should be reserved for -pass-through keyword arguments, as in the examaple above. If I intend -for all the keyword args to be used in some function and not passed -on, I just use the key/value keyword args in the function definition -rather than the **kwargs idiom. - -In some cases I want to consume some keys and pass through the others, -in which case I pop the ones I want to use locally and pass on the -rest, eg I pop scalex and scaley in Axes.plot and assume the rest are -Line2D keyword arguments. As an example of a pop, passthrough -usage, see Axes.plot: - - # in axes.py - def plot(self, *args, **kwargs): - scalex = kwargs.pop('scalex', True) - scaley = kwargs.pop('scaley', True) - if not self._hold: self.cla() - lines = [] - for line in self._get_lines(*args, **kwargs): - self.add_line(line) - lines.append(line) - -The matplotlib.cbook function popd() is rendered -obsolete by the pop() dictionary method introduced in Python 2.3, -so it should not be used for new code. - -Note there is a use case when kwargs are meant to be used locally in -the function (not passed on), but you still need the **kwargs idiom. -That is when you want to use *args to allow variable numbers of -non-keyword args. In this case, python will not allow you to use -named keyword args after the *args usage, so you will be forced to use -**kwargs. An example is matplotlib.contour.ContourLabeler.clabel - - # in contour.py - def clabel(self, *args, **kwargs): - fontsize = kwargs.get('fontsize', None) - inline = kwargs.get('inline', 1) - self.fmt = kwargs.get('fmt', '%1.3f') - colors = kwargs.get('colors', None) - if len(args) == 0: - levels = self.levels - indices = range(len(self.levels)) - elif len(args) == 1: - ...etc... - -== Class documentation == - -matplotlib uses artist instrospection of docstrings to support -properties. All properties that you want to support through setp and -getp should have a set_property and get_property method in the Artist -class. Yes, this is not ideal given python properties or enthought -traits, but it is a historical legacy for now. The setter methods use -the docstring with the ACCEPTS token to indicate the type of argument -the method accepts. Eg in matplotlib.lines.Line2D - - # in lines.py - def set_linestyle(self, linestyle): - """ - Set the linestyle of the line - - ACCEPTS: [ '-' | '--' | '-.' | ':' | 'steps' | 'None' | ' ' | '' ] - """ - - -Since matplotlib uses a lot of pass through kwargs, eg in every -function that creates a line (plot, semilogx, semilogy, etc...), it -can be difficult for the new user to know which kwargs are supported. -I have developed a docstring interpolation scheme to support -documentation of every function that takes a **kwargs. The -requirements are: - - 1) single point of configuration so changes to the properties don't - require multiple docstring edits - - 2) as automated as possible so that as properties change the docs - are updated automagically. - -I have added a matplotlib.artist.kwdocd and kwdoc() to faciliate this. -They combines python string interpolation in the docstring with the -matplotlib artist introspection facility that underlies setp and getp. -The kwdocd is a single dictionary that maps class name to a docstring -of kwargs. Here is an example from matplotlib.lines - - # in lines.py - artist.kwdocd['Line2D'] = artist.kwdoc(Line2D) - -Then in any function accepting Line2D passthrough kwargs, eg -matplotlib.axes.Axes.plot - - # in axes.py -... - def plot(self, *args, **kwargs): - """ - Some stuff omitted - - The kwargs are Line2D properties: - %(Line2D)s - - kwargs scalex and scaley, if defined, are passed on - to autoscale_view to determine whether the x and y axes are - autoscaled; default True. See Axes.autoscale_view for more - information - """ - pass - plot.__doc__ = cbook.dedent(plot.__doc__) % artist.kwdocd - -Note there is a problem for Artist __init__ methods, eg Patch.__init__ -which supports Patch kwargs, since the artist inspector cannot work -until the class is fully defined and we can't modify the -Patch.__init__.__doc__ docstring outside the class definition. I have -made some manual hacks in this case which violates the "single entry -point" requirement above; hopefully we'll find a more elegant solution -before too long - Modified: trunk/matplotlib/docs/devel/coding_guide.rst =================================================================== --- trunk/matplotlib/docs/devel/coding_guide.rst 2008-05-25 16:57:31 UTC (rev 5264) +++ trunk/matplotlib/docs/devel/coding_guide.rst 2008-05-25 20:58:06 UTC (rev 5265) @@ -13,12 +13,12 @@ Checking out the main source:: svn co https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/trunk/\ - matplotlib matplotlib --username=youruser --password=yourpass + matplotlib mpl --username=youruser --password=yourpass Branch checkouts, eg the maintenance branch:: svn co https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/branches/\ - v0_91_maint mplv0_91_maint + v0_91_maint mpl91 Committing changes ================== Modified: trunk/matplotlib/examples/api/logo2.py =================================================================== --- trunk/matplotlib/examples/api/logo2.py 2008-05-25 16:57:31 UTC (rev 5264) +++ trunk/matplotlib/examples/api/logo2.py 2008-05-25 20:58:06 UTC (rev 5265) @@ -14,9 +14,12 @@ ax = fig.add_axes([0.05, 0.05, 0.2, 01], polar=True) ax.axesPatch.set_alpha(axalpha) N = 20 -theta = np.arange(0.0, 2*np.pi, 2*np.pi/N) +theta = np.arange(0.0, 2*np.pi, 2*np.pi/N) + np.pi radii = 10*np.random.rand(N) -width = np.pi/4*np.random.rand(N) +width = np.pi/6*np.random.rand(N) +#radii = np.log(np.arange(1,N+1)) +#width = np.arange(N, dtype=float)/N*np.pi/8 + bars = ax.bar(theta, radii, width=width, bottom=0.0) for r,bar in zip(radii, bars): bar.set_facecolor( cm.jet(r/10.)) @@ -33,7 +36,8 @@ x = mu + sigma*np.random.randn(10000) # the histogram of the data -n, bins, patches = axhist.hist(x, 50, normed=1, facecolor='green', edgecolor='green', alpha=0.75) +n, bins, patches = axhist.hist(x, 50, normed=1, + facecolor='green', edgecolor='green', alpha=0.75) y = mlab.normpdf( bins, mu, sigma) @@ -51,8 +55,10 @@ #the math background tex = r"$W^{3\beta}_{\delta_1 \rho_1 \sigma_2} = U^{3\beta}_{\delta_1 \rho_1} + \frac{1}{8 \pi 2} \int^{\alpha_2}_{\alpha_2} d \alpha^\prime_2 \left[\frac{ U^{2\beta}_{\delta_1 \rho_1} - \alpha^\prime_2U^{1\beta}_{\rho_1 \sigma_2} }{U^{0\beta}_{\rho_1 \sigma_2}}\right]$" +radargreen = '#d5de9c' +orange = '#ee8d18' axback.text(0.5, 0.5, tex, - transform=axback.transAxes, color="0.5", alpha=0.5, fontsize=40, + transform=axback.transAxes, color='black', alpha=0.25, fontsize=40, ha='center', va='center') axback.set_axis_off() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jd...@us...> - 2008-05-25 20:58:37
|
Revision: 5266 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5266&view=rev Author: jdh2358 Date: 2008-05-25 13:58:35 -0700 (Sun, 25 May 2008) Log Message: ----------- renamed docs dir to doc Added Paths: ----------- trunk/matplotlib/doc/ Removed Paths: ------------- trunk/matplotlib/docs/ Copied: trunk/matplotlib/doc (from rev 5265, trunk/matplotlib/docs) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |