|
From: <md...@us...> - 2008-06-20 15:03:20
|
Revision: 5615
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5615&view=rev
Author: mdboom
Date: 2008-06-20 08:03:18 -0700 (Fri, 20 Jun 2008)
Log Message:
-----------
Fix bug: [ 1994535 ] still missing lines on graph with svn (r 5548).
Modified Paths:
--------------
trunk/matplotlib/CHANGELOG
trunk/matplotlib/lib/matplotlib/collections.py
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2008-06-20 14:47:17 UTC (rev 5614)
+++ trunk/matplotlib/CHANGELOG 2008-06-20 15:03:18 UTC (rev 5615)
@@ -1,3 +1,6 @@
+2008-06-20 Added closed kwarg to PolyCollection. Fixes bug [ 1994535
+ ] still missing lines on graph with svn (r 5548). - MGD
+
2008-06-20 Added set/get_closed method to Polygon; fixes error
in hist - MM
Modified: trunk/matplotlib/lib/matplotlib/collections.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/collections.py 2008-06-20 14:47:17 UTC (rev 5614)
+++ trunk/matplotlib/lib/matplotlib/collections.py 2008-06-20 15:03:18 UTC (rev 5615)
@@ -514,7 +514,7 @@
renderer.close_group(self.__class__.__name__)
class PolyCollection(Collection):
- def __init__(self, verts, sizes = None, **kwargs):
+ def __init__(self, verts, sizes = None, closed = True, **kwargs):
"""
*verts* is a sequence of ( *verts0*, *verts1*, ...) where
*verts_i* is a sequence of *xy* tuples of vertices, or an
@@ -523,16 +523,26 @@
*sizes* gives the area of the circle circumscribing the
polygon in points^2.
+ *closed*, when *True*, will explicitly close the polygon.
+
%(Collection)s
"""
Collection.__init__(self,**kwargs)
self._sizes = sizes
- self.set_verts(verts)
+ self.set_verts(verts, closed)
__init__.__doc__ = cbook.dedent(__init__.__doc__) % artist.kwdocd
- def set_verts(self, verts):
+ def set_verts(self, verts, closed=True):
'''This allows one to delay initialization of the vertices.'''
- self._paths = [mpath.Path(v) for v in verts]
+ if closed:
+ self._paths = []
+ for xy in verts:
+ xy = np.asarray(xy)
+ if len(xy) and (xy[0] != xy[-1]).any():
+ xy = np.concatenate([xy, [xy[0]]])
+ self._paths.append(mpath.Path(xy))
+ else:
+ self._paths = [mpath.Path(xy) for xy in verts]
def get_paths(self):
return self._paths
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2008-06-20 15:24:31
|
Revision: 5616
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5616&view=rev
Author: mdboom
Date: 2008-06-20 08:24:16 -0700 (Fri, 20 Jun 2008)
Log Message:
-----------
Fix bug: [ 1978629 ] scale documentation missing/incorrect for log
Modified Paths:
--------------
trunk/matplotlib/CHANGELOG
trunk/matplotlib/lib/matplotlib/axes.py
trunk/matplotlib/lib/matplotlib/pyplot.py
trunk/matplotlib/lib/matplotlib/scale.py
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2008-06-20 15:03:18 UTC (rev 5615)
+++ trunk/matplotlib/CHANGELOG 2008-06-20 15:24:16 UTC (rev 5616)
@@ -1,3 +1,5 @@
+2008-06-20 [ 1978629 ] scale documentation missing/incorrect for log - MGD
+
2008-06-20 Added closed kwarg to PolyCollection. Fixes bug [ 1994535
] still missing lines on graph with svn (r 5548). - MGD
Modified: trunk/matplotlib/lib/matplotlib/axes.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/axes.py 2008-06-20 15:03:18 UTC (rev 5615)
+++ trunk/matplotlib/lib/matplotlib/axes.py 2008-06-20 15:24:16 UTC (rev 5616)
@@ -1765,12 +1765,15 @@
Different kwargs are accepted, depending on the scale:
%(scale_docs)s
- """ % {'scale': ' | '.join([repr(x) for x in mscale.get_scale_names()]),
- 'scale_docs': mscale.get_scale_docs().strip()}
+ """
self.xaxis.set_scale(value, **kwargs)
self.autoscale_view()
self._update_transScale()
+ set_xscale.__doc__ = cbook.dedent(set_xscale.__doc__) % {
+ 'scale': ' | '.join([repr(x) for x in mscale.get_scale_names()]),
+ 'scale_docs': mscale.get_scale_docs().strip()}
+
def get_xticks(self, minor=False):
'Return the x ticks as a list of locations'
return self.xaxis.get_ticklocs(minor=minor)
@@ -1929,12 +1932,15 @@
Different kwargs are accepted, depending on the scale:
%(scale_docs)s
- """ % {'scale': ' | '.join([repr(x) for x in mscale.get_scale_names()]),
- 'scale_docs': mscale.get_scale_docs().strip()}
+ """
self.yaxis.set_scale(value, **kwargs)
self.autoscale_view()
self._update_transScale()
+ set_yscale.__doc__ = cbook.dedent(set_yscale.__doc__) % {
+ 'scale': ' | '.join([repr(x) for x in mscale.get_scale_names()]),
+ 'scale_docs': mscale.get_scale_docs().strip()}
+
def get_yticks(self, minor=False):
'Return the y ticks as a list of locations'
return self.yaxis.get_ticklocs(minor=minor)
Modified: trunk/matplotlib/lib/matplotlib/pyplot.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/pyplot.py 2008-06-20 15:03:18 UTC (rev 5615)
+++ trunk/matplotlib/lib/matplotlib/pyplot.py 2008-06-20 15:24:16 UTC (rev 5616)
@@ -810,34 +810,44 @@
def xscale(*args, **kwargs):
"""
+ call signature::
+
+ xscale(scale, **kwargs)
+
Set the scaling for the x-axis: %(scale)s
Different keywords may be accepted, depending on the scale:
%(scale_docs)s
- """ % {'scale': ' | '.join([repr(x) for x in get_scale_names()]),
- 'scale_docs': get_scale_docs()}
+ """
ax = gca()
ret = ax.set_xscale(*args, **kwargs)
draw_if_interactive()
return ret
+xscale.__doc__ = dedent(xscale.__doc__) % {
+ 'scale': ' | '.join([repr(x) for x in get_scale_names()]),
+ 'scale_docs': get_scale_docs()}
-
def yscale(*args, **kwargs):
"""
+ call signature::
+
+ xscale(scale, **kwargs)
+
Set the scaling for the y-axis: %(scale)s
Different keywords may be accepted, depending on the scale:
%(scale_docs)s
- """ % {'scale': ' | '.join([repr(x) for x in get_scale_names()]),
- 'scale_docs': get_scale_docs()}
+ """
ax = gca()
ret = ax.set_yscale(*args, **kwargs)
draw_if_interactive()
return ret
+yscale.__doc__ = dedent(yscale.__doc__) % {
+ 'scale': ' | '.join([repr(x) for x in get_scale_names()]),
+ 'scale_docs': get_scale_docs()}
-
def xticks(*args, **kwargs):
"""
Set/Get the xlimits of the current ticklocs and labels::
Modified: trunk/matplotlib/lib/matplotlib/scale.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/scale.py 2008-06-20 15:03:18 UTC (rev 5615)
+++ trunk/matplotlib/lib/matplotlib/scale.py 2008-06-20 15:24:16 UTC (rev 5616)
@@ -172,10 +172,18 @@
def __init__(self, axis, **kwargs):
"""
- basex/basey: The base of the logarithm
+ *basex*/*basey*:
+ The base of the logarithm
- subsx/subsy: The number of subticks to draw between each major
- tick
+ *subsx*/*subsy*:
+ Where to place the subticks between each major tick.
+ Should be a sequence of integers. For example, in a log10
+ scale::
+
+ [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
+
+ will place 10 logarithmically spaced minor ticks between
+ each major tick.
"""
if axis.axis_name == 'x':
base = kwargs.pop('basex', 10.0)
@@ -273,14 +281,22 @@
def __init__(self, axis, **kwargs):
"""
- basex/basey: The base of the logarithm
+ *basex*/*basey*:
+ The base of the logarithm
- linthreshx/linthreshy: The range (-x, x) within which the plot
- is linear (to avoid having the plot go to infinity around
- zero).
+ *linthreshx*/*linthreshy*:
+ The range (-*x*, *x*) within which the plot is linear (to
+ avoid having the plot go to infinity around zero).
- subsx/subsy: The number of subticks to render between each
- major tick.
+ *subsx*/*subsy*:
+ Where to place the subticks between each major tick.
+ Should be a sequence of integers. For example, in a log10
+ scale::
+
+ [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
+
+ will place 10 logarithmically spaced minor ticks between
+ each major tick.
"""
if axis.axis_name == 'x':
base = kwargs.pop('basex', 10.0)
@@ -340,9 +356,8 @@
scale_class = _scale_mapping[name]
docs.append(" '%s'" % name)
docs.append("")
- class_docs = textwrap.wrap(
- dedent(scale_class.__init__.__doc__), initial_indent=" " * 8,
- subsequent_indent = " " * 8)
- docs.extend(class_docs)
+ class_docs = dedent(scale_class.__init__.__doc__)
+ class_docs = "".join([" %s\n" % x for x in class_docs.split("\n")])
+ docs.append(class_docs)
docs.append("")
return "\n".join(docs)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2008-06-21 17:13:24
|
Revision: 5626
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5626&view=rev
Author: jdh2358
Date: 2008-06-21 10:07:25 -0700 (Sat, 21 Jun 2008)
Log Message:
-----------
minor docstring cleanups
Modified Paths:
--------------
trunk/matplotlib/MANIFEST.in
trunk/matplotlib/doc/faq/installing_faq.rst
trunk/matplotlib/lib/matplotlib/lines.py
trunk/matplotlib/lib/matplotlib/patches.py
Modified: trunk/matplotlib/MANIFEST.in
===================================================================
--- trunk/matplotlib/MANIFEST.in 2008-06-21 13:35:30 UTC (rev 5625)
+++ trunk/matplotlib/MANIFEST.in 2008-06-21 17:07:25 UTC (rev 5626)
@@ -15,7 +15,6 @@
include lib/matplotlib/mpl-data/fonts/afm/*
recursive-include license LICENSE*
recursive-include examples *
-recursive-include doc *
recursive-include src *.cpp *.c *.h
recursive-include CXX *.cxx *.hxx *.c *.h
recursive-include agg24 *
Modified: trunk/matplotlib/doc/faq/installing_faq.rst
===================================================================
--- trunk/matplotlib/doc/faq/installing_faq.rst 2008-06-21 13:35:30 UTC (rev 5625)
+++ trunk/matplotlib/doc/faq/installing_faq.rst 2008-06-21 17:07:25 UTC (rev 5626)
@@ -104,7 +104,7 @@
people use matplotlib interactively from the python shell and have
plotting windows pop up when they type commands. Some people embed
matplotlib into graphical user interfaces like wxpython or pygtk to
-build rich applications. Others use matplotlib in batch scripts, to
+build rich applications. Others use matplotlib in batch scripts to
generate postscript images from some numerical simulations, and still
others in web application servers to dynamically serve up graphs.
Modified: trunk/matplotlib/lib/matplotlib/lines.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/lines.py 2008-06-21 13:35:30 UTC (rev 5625)
+++ trunk/matplotlib/lib/matplotlib/lines.py 2008-06-21 17:07:25 UTC (rev 5626)
@@ -53,6 +53,7 @@
y.filled()[ii[1,0]:ii[1,1]]
# returns np.array [3,4,]
+
'''
m = np.concatenate(((1,), mask, (1,)))
indices = np.arange(len(mask) + 1)
Modified: trunk/matplotlib/lib/matplotlib/patches.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/patches.py 2008-06-21 13:35:30 UTC (rev 5625)
+++ trunk/matplotlib/lib/matplotlib/patches.py 2008-06-21 17:07:25 UTC (rev 5626)
@@ -221,9 +221,10 @@
CURRENT LIMITATIONS:
- 1. Hatching is supported in the PostScript backend only.
+ 1. Hatching is supported in the PostScript backend only.
- 2. Hatching is done with solid black lines of width 0.
+ 2. Hatching is done with solid black lines of width 0.
+
"""
self._hatch = h
@@ -345,6 +346,7 @@
def __init__(self, xy, width, height, **kwargs):
"""
+
*fill* is a boolean indicating whether to fill the rectangle
Valid kwargs are:
@@ -460,6 +462,8 @@
def __init__(self, xy, numVertices, radius=5, orientation=0,
**kwargs):
"""
+ Constructor arguments:
+
*xy*
A length 2 tuple (*x*, *y*) of the center.
@@ -685,19 +689,21 @@
head_width=None, head_length=None, shape='full', overhang=0, \
head_starts_at_zero=False,**kwargs):
"""
- *length_includes_head*:
- *True* if head is counted in calculating the length.
+ Constructor arguments
- *shape*: ['full', 'left', 'right']
+ *length_includes_head*:
+ *True* if head is counted in calculating the length.
- *overhang*:
- distance that the arrow is swept back (0 overhang means
- triangular shape).
+ *shape*: ['full', 'left', 'right']
- *head_starts_at_zero*:
- If *True*, the head starts being drawn at coordinate 0
- instead of ending at coordinate 0.
+ *overhang*:
+ distance that the arrow is swept back (0 overhang means
+ triangular shape).
+ *head_starts_at_zero*:
+ If *True*, the head starts being drawn at coordinate 0
+ instead of ending at coordinate 0.
+
Valid kwargs are:
%(Patch)s
@@ -761,6 +767,8 @@
def __init__(self, figure, xytip, xybase, width=4, frac=0.1, headwidth=12, **kwargs):
"""
+ Constructor arguments:
+
*xytip*
(*x*, *y*) location of arrow tip
@@ -972,6 +980,8 @@
def __init__(self, xy, width, height, angle=0.0, theta1=0.0, theta2=360.0, **kwargs):
"""
+ The following args are supported:
+
*xy*
center of ellipse
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ds...@us...> - 2008-06-22 10:05:26
|
Revision: 5623
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5623&view=rev
Author: dsdale
Date: 2008-06-21 06:09:07 -0700 (Sat, 21 Jun 2008)
Log Message:
-----------
fix marker placement bug in backend_ps
Modified Paths:
--------------
trunk/matplotlib/CHANGELOG
trunk/matplotlib/lib/matplotlib/backends/backend_ps.py
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2008-06-20 19:46:05 UTC (rev 5622)
+++ trunk/matplotlib/CHANGELOG 2008-06-21 13:09:07 UTC (rev 5623)
@@ -1,3 +1,5 @@
+2008-06-21 fix marker placement bug in backend_ps - DSD
+
2008-06-20 [ 1978629 ] scale documentation missing/incorrect for log - MGD
2008-06-20 Added closed kwarg to PolyCollection. Fixes bug [ 1994535
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_ps.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_ps.py 2008-06-20 19:46:05 UTC (rev 5622)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_ps.py 2008-06-21 13:09:07 UTC (rev 5623)
@@ -501,7 +501,7 @@
tpath = trans.transform_path(path)
for x, y in tpath.vertices:
- ps_cmd.append("%1.3g %1.3g o" % (x, y))
+ ps_cmd.append("%g %g o" % (x, y))
ps = '\n'.join(ps_cmd)
self._draw_ps(ps, gc, rgbFace, fill=False, stroke=False)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2008-06-22 10:25:47
|
Revision: 5618
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5618&view=rev
Author: jdh2358
Date: 2008-06-20 10:09:12 -0700 (Fri, 20 Jun 2008)
Log Message:
-----------
added origin support for composite images
Modified Paths:
--------------
trunk/matplotlib/examples/api/mathtext_asarray.py
trunk/matplotlib/examples/pylab_examples/figimage_demo.py
trunk/matplotlib/lib/matplotlib/axes.py
trunk/matplotlib/lib/matplotlib/backends/backend_gtkagg.py
trunk/matplotlib/lib/matplotlib/figure.py
trunk/matplotlib/src/_gtkagg.cpp
trunk/matplotlib/src/_image.cpp
Modified: trunk/matplotlib/examples/api/mathtext_asarray.py
===================================================================
--- trunk/matplotlib/examples/api/mathtext_asarray.py 2008-06-20 15:32:40 UTC (rev 5617)
+++ trunk/matplotlib/examples/api/mathtext_asarray.py 2008-06-20 17:09:12 UTC (rev 5618)
@@ -10,6 +10,7 @@
parser = mathtext.MathTextParser("Bitmap")
+
parser.to_png('test2.png', r'$\left[\left\lfloor\frac{5}{\frac{\left(3\right)}{4}} y\right)\right]$', color='green', fontsize=14, dpi=100)
@@ -20,5 +21,4 @@
fig.figimage(rgba1.astype(float)/255., 100, 100)
fig.figimage(rgba2.astype(float)/255., 100, 300)
-
plt.show()
Modified: trunk/matplotlib/examples/pylab_examples/figimage_demo.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/figimage_demo.py 2008-06-20 15:32:40 UTC (rev 5617)
+++ trunk/matplotlib/examples/pylab_examples/figimage_demo.py 2008-06-20 17:09:12 UTC (rev 5618)
@@ -13,8 +13,9 @@
im1 = figimage(Z, xo=50, yo=0)
im2 = figimage(Z, xo=100, yo=100, alpha=.8)
#gray() # overrides current and sets default
-savefig('figimage_demo')
+#savefig('figimage_demo')
show()
+
Modified: trunk/matplotlib/lib/matplotlib/axes.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/axes.py 2008-06-20 15:32:40 UTC (rev 5617)
+++ trunk/matplotlib/lib/matplotlib/axes.py 2008-06-20 17:09:12 UTC (rev 5618)
@@ -1442,6 +1442,9 @@
im = mimage.from_images(height,
width,
ims)
+ if self.images[0].origin=='upper':
+ im.flipud_out()
+
im.is_grayscale = False
l, b, w, h = self.bbox.bounds
# composite images need special args so they will not
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_gtkagg.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_gtkagg.py 2008-06-20 15:32:40 UTC (rev 5617)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_gtkagg.py 2008-06-20 17:09:12 UTC (rev 5618)
@@ -47,7 +47,7 @@
class FigureCanvasGTKAgg(FigureCanvasGTK, FigureCanvasAgg):
filetypes = FigureCanvasGTK.filetypes.copy()
filetypes.update(FigureCanvasAgg.filetypes)
-
+
def configure_event(self, widget, event=None):
if DEBUG: print 'FigureCanvasGTKAgg.configure_event'
@@ -80,6 +80,14 @@
ren = self.get_renderer()
w = int(ren.width)
h = int(ren.height)
+
+ # There apparently is a bug here on some versions of pygtk
+ # (2.6) that crops up in corner cases. Eg, in
+ # figimage_demo.py, there is background pixel noise because
+ # the figure frame is off and the blended image background has
+ # alpha 0. and you see the uninitialzed data ("screen noise").
+ # If in _image.cpp Image:from_image you fill the background
+ # with a non transparent value, it goes away.
pixbuf = gtk.gdk.pixbuf_new_from_data(
buf, gtk.gdk.COLORSPACE_RGB, True, 8, w, h, w*4)
pixmap.draw_pixbuf(pixmap.new_gc(), pixbuf, 0, 0, 0, 0, w, h,
Modified: trunk/matplotlib/lib/matplotlib/figure.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/figure.py 2008-06-20 15:32:40 UTC (rev 5617)
+++ trunk/matplotlib/lib/matplotlib/figure.py 2008-06-20 17:09:12 UTC (rev 5618)
@@ -807,6 +807,9 @@
im = _image.from_images(self.bbox.height * mag,
self.bbox.width * mag,
ims)
+ if self.images[0].origin=='upper':
+ im.flipud_out()
+
im.is_grayscale = False
l, b, w, h = self.bbox.bounds
clippath, affine = self.get_transformed_clip_path_and_affine()
Modified: trunk/matplotlib/src/_gtkagg.cpp
===================================================================
--- trunk/matplotlib/src/_gtkagg.cpp 2008-06-20 15:32:40 UTC (rev 5617)
+++ trunk/matplotlib/src/_gtkagg.cpp 2008-06-20 17:09:12 UTC (rev 5618)
@@ -94,8 +94,9 @@
destrbuf.attach(destbuffer, destwidth, destheight, deststride);
pixfmt destpf(destrbuf);
renderer_base destrb(destpf);
- //destrb.clear(agg::rgba(1, 0, 0));
+ //destrb.clear(agg::rgba(1, 1, 1, 0));
+
agg::rect_base<int> region(destx, desty, (int)r, srcheight-(int)b);
destrb.copy_from(*aggRenderer->renderingBuffer, ®ion,
-destx, -desty);
Modified: trunk/matplotlib/src/_image.cpp
===================================================================
--- trunk/matplotlib/src/_image.cpp 2008-06-20 15:32:40 UTC (rev 5617)
+++ trunk/matplotlib/src/_image.cpp 2008-06-20 17:09:12 UTC (rev 5618)
@@ -739,11 +739,14 @@
renderer_base rb(pixf);
+ //clear the background of the rendering buffer with alpha 1 and the
+ //gtkagg screen noise problem in figimage_demo.py goes away -- see
+ //comment backend_gtkagg.py _render_figure method JDH
+ //rb.clear(agg::rgba(1, 1, 1, 1));
+
for (size_t imnum=0; imnum< N; imnum++) {
tup = Py::Tuple(tups[imnum]);
Image* thisim = static_cast<Image*>(tup[0].ptr());
- if (imnum==0)
- rb.clear(thisim->bg);
ox = Py::Int(tup[1]);
oy = Py::Int(tup[2]);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2008-06-22 13:53:02
|
Revision: 5629
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5629&view=rev
Author: jdh2358
Date: 2008-06-22 06:52:43 -0700 (Sun, 22 Jun 2008)
Log Message:
-----------
removed axes3d
Modified Paths:
--------------
trunk/matplotlib/API_CHANGES
trunk/matplotlib/CHANGELOG
trunk/matplotlib/examples/pylab_examples/hline_demo.py
trunk/matplotlib/examples/pylab_examples/image_demo.py
trunk/matplotlib/examples/tests/backend_driver.py
trunk/matplotlib/lib/matplotlib/axes3d.py
Removed Paths:
-------------
trunk/matplotlib/examples/pylab_examples/simple3d.py
trunk/matplotlib/examples/user_interfaces/simple3d_oo.py
trunk/matplotlib/lib/matplotlib/art3d.py
trunk/matplotlib/lib/matplotlib/axis3d.py
trunk/matplotlib/lib/matplotlib/proj3d.py
Modified: trunk/matplotlib/API_CHANGES
===================================================================
--- trunk/matplotlib/API_CHANGES 2008-06-22 08:19:56 UTC (rev 5628)
+++ trunk/matplotlib/API_CHANGES 2008-06-22 13:52:43 UTC (rev 5629)
@@ -1,4 +1,12 @@
+Changes for 0.98.1
+==================
+* Removed broken axes3d support and replaced it with a non implemented
+ error pointing to 0.91.x
+
+Changes for 0.98.0
+==================
+
matplotlib.image.imread now no longer always returns RGBA -- if
the image is luminance or RGB, it will return a MxN or MxNx3 array
if possible. Also uint8 is no longer always forced to float.
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2008-06-22 08:19:56 UTC (rev 5628)
+++ trunk/matplotlib/CHANGELOG 2008-06-22 13:52:43 UTC (rev 5629)
@@ -1,3 +1,6 @@
+2008-06-22 Removed axes3d support and replaced it with a
+ NotImplementedError for one release cycle
+
2008-06-21 fix marker placement bug in backend_ps - DSD
2008-06-20 [ 1978629 ] scale documentation missing/incorrect for log - MGD
Modified: trunk/matplotlib/examples/pylab_examples/hline_demo.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/hline_demo.py 2008-06-22 08:19:56 UTC (rev 5628)
+++ trunk/matplotlib/examples/pylab_examples/hline_demo.py 2008-06-22 13:52:43 UTC (rev 5629)
@@ -17,5 +17,6 @@
hlines(t, [0], s)
xlabel('time (s)')
title('Comparison of model with data')
+savefig('test')
show()
Modified: trunk/matplotlib/examples/pylab_examples/image_demo.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/image_demo.py 2008-06-22 08:19:56 UTC (rev 5628)
+++ trunk/matplotlib/examples/pylab_examples/image_demo.py 2008-06-22 13:52:43 UTC (rev 5629)
@@ -11,6 +11,6 @@
im = imshow(Z, interpolation='bilinear', cmap=cm.gray,
origin='lower', extent=[-3,3,-3,3])
-#savefig('image_demo')
+savefig('image_demo')
show()
Deleted: trunk/matplotlib/examples/pylab_examples/simple3d.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/simple3d.py 2008-06-22 08:19:56 UTC (rev 5628)
+++ trunk/matplotlib/examples/pylab_examples/simple3d.py 2008-06-22 13:52:43 UTC (rev 5629)
@@ -1,31 +0,0 @@
-#!/usr/bin/env python
-
-from numpy import arange, cos, linspace, ones, pi, sin, outer
-
-import pylab
-import matplotlib.axes3d as axes3d
-
-
-fig = pylab.gcf()
-
-ax3d = axes3d.Axes3D(fig)
-plt = fig.axes.append(ax3d)
-
-delta = pi / 199.0
-u = arange(0, 2*pi+(delta*2), delta*2)
-v = arange(0, pi+delta, delta)
-
-x = outer(cos(u),sin(v))
-y = outer(sin(u),sin(v))
-z = outer(ones(u.shape), cos(v))
-
-#ax3d.plot_wireframe(x,y,z)
-surf = ax3d.plot_surface(x, y, z)
-surf.set_array(linspace(0, 1.0, len(v)))
-
-ax3d.set_xlabel('X')
-ax3d.set_ylabel('Y')
-ax3d.set_zlabel('Z')
-
-pylab.show()
-#pylab.savefig('simple3d.svg')
Modified: trunk/matplotlib/examples/tests/backend_driver.py
===================================================================
--- trunk/matplotlib/examples/tests/backend_driver.py 2008-06-22 08:19:56 UTC (rev 5628)
+++ trunk/matplotlib/examples/tests/backend_driver.py 2008-06-22 13:52:43 UTC (rev 5629)
@@ -132,9 +132,11 @@
import subprocess
def run(arglist):
try:
- subprocess.call(arglist)
+ ret = subprocess.call(arglist)
except KeyboardInterrupt:
sys.exit()
+ else:
+ return ret
except ImportError:
def run(arglist):
os.system(' '.join(arglist))
@@ -198,12 +200,13 @@
tmpfile.close()
start_time = time.time()
program = [x % {'name': basename} for x in python]
- run(program + [tmpfile_name, switchstring])
+ ret = run(program + [tmpfile_name, switchstring])
end_time = time.time()
- print (end_time - start_time)
+ print (end_time - start_time), ret
#os.system('%s %s %s' % (python, tmpfile_name, switchstring))
os.remove(tmpfile_name)
+
if __name__ == '__main__':
times = {}
default_backends = ['agg', 'ps', 'svg', 'pdf', 'template']
Deleted: trunk/matplotlib/examples/user_interfaces/simple3d_oo.py
===================================================================
--- trunk/matplotlib/examples/user_interfaces/simple3d_oo.py 2008-06-22 08:19:56 UTC (rev 5628)
+++ trunk/matplotlib/examples/user_interfaces/simple3d_oo.py 2008-06-22 13:52:43 UTC (rev 5629)
@@ -1,64 +0,0 @@
-#!/usr/bin/env python
-
-import matplotlib
-matplotlib.use('WXAgg')
-
-from wx import *
-import matplotlib.axes3d
-import matplotlib.mlab
-import numpy as npy
-from matplotlib.figure import Figure
-from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg, FigureManager, NavigationToolbar2WxAgg
-
-class PlotFigure(Frame):
- def __init__(self):
- Frame.__init__(self, None, -1, "Test embedded wxFigure")
-
- self.fig = Figure((9,8), 75)
- self.canvas = FigureCanvasWxAgg(self, -1, self.fig)
- self.toolbar = NavigationToolbar2WxAgg(self.canvas)
- self.toolbar.Realize()
-
- self.figmgr = FigureManager(self.canvas, 1, self)
- tw, th = self.toolbar.GetSizeTuple()
- fw, fh = self.canvas.GetSizeTuple()
- self.toolbar.SetSize(Size(fw, th))
- sizer = BoxSizer(VERTICAL)
-
- # This way of adding to sizer allows resizing
- sizer.Add(self.canvas, 1, LEFT|TOP|GROW)
- sizer.Add(self.toolbar, 0, GROW)
- self.SetSizer(sizer)
- self.Fit()
-
- self.plot3d()
-
- def plot3d(self):
- # sample taken from http://www.scipy.org/Cookbook/Matplotlib/mplot3D
- ax3d = matplotlib.axes3d.Axes3D(self.fig)
- plt = self.fig.axes.append(ax3d)
-
- delta = npy.pi / 199.0
- u = npy.arange(0, 2*npy.pi+(delta*2), delta*2)
- v = npy.arange(0, npy.pi+delta, delta)
-
- x = npy.cos(u)[:,npy.newaxis] * npy.sin(v)[npy.newaxis,:]
- y = npy.sin(u)[:,npy.newaxis] * npy.sin(v)[npy.newaxis,:]
- z = npy.ones_like(u)[:,npy.newaxis] * npy.cos(v)[npy.newaxis,:]
- # (there is probably a better way to calculate z)
- print x.shape, y.shape, z.shape
-
- #ax3d.plot_wireframe(x,y,z)
- surf = ax3d.plot_surface(x, y, z)
- surf.set_array(matplotlib.mlab.linspace(0, 1.0, len(v)))
-
- ax3d.set_xlabel('X')
- ax3d.set_ylabel('Y')
- ax3d.set_zlabel('Z')
- #self.fig.savefig('globe')
-
-if __name__ == '__main__':
- app = PySimpleApp(0)
- frame = PlotFigure()
- frame.Show()
- app.MainLoop()
Deleted: trunk/matplotlib/lib/matplotlib/art3d.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/art3d.py 2008-06-22 08:19:56 UTC (rev 5628)
+++ trunk/matplotlib/lib/matplotlib/art3d.py 2008-06-22 13:52:43 UTC (rev 5629)
@@ -1,464 +0,0 @@
-#!/usr/bin/python
-# art3d.py
-#
-"""
-Wrap 2D artists so that they can pretend to be 3D
-"""
-
-import lines
-from collections import LineCollection, PolyCollection
-import text
-
-from colors import Normalize
-
-import numpy as np
-import proj3d
-
-class Wrap2D:
- """Wrapper which wraps a 2D object and makes it 3D
-
- Artists are normally rendered by calling the draw method, this class
- causes call_draw3d to be called instead.
- This in turn calls
- draw3d which should play with the 2D coordinates and eventually
- call the original self.draw method through self.orig_draw.
-
- overrides the draw method with draw3d
- remembers the original draw method of the wrapped 2d instance
- """
- def __init__(self, inst2d):
- self.__dict__['_wrapped'] = inst2d
- self.__dict__['remembered'] = {}
- #
- inst2d.orig_draw = inst2d.draw
- self.draw2d = inst2d.draw
- inst2d.draw = self.call_draw3d
-
- def remember(self, *attrs):
- """
- Remember some attributes in the wrapped class
- """
- for attr in attrs:
- assert(hasattr(self._wrapped, attr))
- self.remembered[attr] = 1
-
- def __getattr__(self, k):
- return getattr(self.__dict__['_wrapped'], k)
-
- def __setattr__(self, k, v):
- setattr(self.__dict__['_wrapped'], k, v)
-
- def call_draw3d(self, renderer):
- for k in self.remembered.keys():
- self.remembered[k] = getattr(self, k)
- #
- self.draw3d(renderer)
- #
- for k in self.remembered.keys():
- setattr(self, k, self.remembered[k])
-
- def draw3d(self, renderer):
- raise ValueError, "draw3d should be overridden"
-
-class Text3DW(Wrap2D):
- """Wrap a 2D text object and make it look vaguely 3D"""
- def __init__(self, inst, z=0, dir='z'):
- Wrap2D.__init__(self, inst)
- self._z = z
- self.dir = dir
-
- def draw3d(self, renderer):
- x,y = self.get_position()
- xs,ys,zs = juggle_axes(x,y,self._z,self.dir)
- xs,ys,zs = proj3d.proj_transform(xs,ys,zs, renderer.M)
- self.set_x(xs)
- self.set_y(ys)
- #text.Text.draw(self._wrapped, renderer)
- self.draw2d(renderer)
- self.set_x(x)
- self.set_y(y)
-
-class Text3D(Text3DW):
- def __init__(self, x=0,y=0,z=0,text='', dir='z'):
- inst = text.Text(x,y,text,*args, **kwargs)
- Text3DW.__init__(self, z,dir, inst)
-
-class oText3D(text.Text):
- def __init__(self, x=0,y=0,z=0,text='', dir='z', *args, **kwargs):
- text.Text.__init__(self, x,y,text,*args,**kwargs)
- self.dir = dir
- self._z = _z
-
- def draw(self, renderer):
- x,y = self.get_position()
- xs,ys,zs = juggle_axes(x,y,self._z,self.dir)
- xs,ys,zs = proj3d.proj_transform(xs,ys,zs, renderer.M)
- self.set_x(xs)
- self.set_y(ys)
- text.Text.draw(self, renderer)
- self.set_x(x)
- self.set_y(y)
-
-class Line3D(lines.Line2D):
- """Make a 2D line pretend to be 3D"""
- def __init__(self, xs,ys,zs, *args, **kwargs):
- lines.Line2D.__init__(self, xs,ys, *args, **kwargs)
- self.xs,self.ys,self.zs = xs,ys,zs
-
- def draw(self, renderer):
- xs,ys,zs = proj3d.proj_transform(self.xs,self.ys,self.zs, renderer.M)
- self._x,self._y = xs,ys
-
- lines.Line2D.draw(self, renderer)
-
-class Line3DCollectionW(Wrap2D):
- def __init__(self, inst, segments):
- Wrap2D.__init__(self, inst)
- self.segments_3d = segments
-
- def draw3d(self, renderer):
- xyslist = [
- proj3d.proj_trans_points(points, renderer.M) for points in
- self.segments_3d]
- segments_2d = [zip(xs,ys) for (xs,ys,zs) in xyslist]
- self._segments = segments_2d
- self.draw2d(renderer)
-
-class Line3DCollection(Line3DCollectionW):
- def __init__(self, segments, *args, **kwargs):
- inst = LineCollection(segments, *args, **kwargs)
- Line3DCollectionW.__init__(self, inst, segments)
-
-class Line2DCollectionW(Wrap2D):
- def __init__(self, inst, z=0, dir='z'):
- Wrap2D.__init__(self, inst)
- self.z = z
- self.dir = dir
- self.remember('_segments')
-
- def draw3d(self, renderer):
- #
- segments_3d = [[juggle_axes(x,y,self.z,self.dir) for (x,y) in points]
- for points in self._segments]
- xyslist = [
- proj3d.proj_trans_points(points, renderer.M) for points in
- segments_3d]
- segments_2d = [zip(xs,ys) for (xs,ys,zs) in xyslist]
- #orig_segments = self._segments
- self._segments = segments_2d
- self.draw2d(renderer)
- #self._segments = orig_segments
-
-class Line3DCollection(Line3DCollectionW):
- def __init__(self, segments, *args, **kwargs):
- inst = LineCollection(segments, *args, **kwargs)
- Line3DCollectionW.__init__(self, inst, segments)
-
-class Patch3D(Wrap2D):
- def __init__(self, inst, zs, dir='z'):
- Wrap2D.__init__(self, inst)
- self.zs = zs
- self.dir = dir
- self.remember('get_verts')
-
- def draw3d(self, renderer):
- xs,ys = zip(*self.get_verts())
- xs,ys,zs = juggle_axes(xs,ys,self.zs,self.dir)
- vxs,vys,vzs,vis = proj3d.proj_transform_clip(xs,ys,zs, renderer.M)
- def get_verts(*args):
- verts = zip(vxs,vys)
- return verts
-
- self.get_verts = get_verts
- self.draw2d(renderer)
-
-class Patch3DCollectionW(Wrap2D):
- def __init__(self, inst, zs, dir='z'):
- Wrap2D.__init__(self, inst)
- self.zs = zs
- self.dir = dir
- self.remember('_offsets','_facecolors','_edgecolors')
-
- def draw3d(self, renderer):
- xs,ys = zip(*self._offsets)
- xs,ys,zs = juggle_axes(xs,ys,self.zs,self.dir)
- if 0:
- vxs,vys,vzs,vis = proj3d.proj_transform_clip(xs,ys,zs, renderer.M)
- # mess with colors
- #
- vxs = [x for x,i in zip(vxs,vis) if i]
- vys = [y for y,i in zip(vys,vis) if i]
- else:
- vxs,vys,vzs,vis = proj3d.proj_transform_clip(xs,ys,zs, renderer.M)
- self._facecolors = zalpha(self._facecolors,vzs)
- self._edgecolors = zalpha(self._edgecolors,vzs)
- self._offsets = zip(vxs,vys)
- self.draw2d(renderer)
-
-class Poly3DCollectionW(Wrap2D):
- def __init__(self, inst, zs=None, dir='z'):
- Wrap2D.__init__(self, inst)
- if not zs:
- zs = [0 for v in inst._verts]
- self.zs = [[z for v in verts] for z,verts in zip(zs,inst._verts)]
- self.dir = dir
- self.remember('_verts','_facecolors','_edgecolors')
-
- def draw3d(self, renderer):
- vverts = []
- for zs,verts in zip(self.zs,self._verts):
- xs,ys = zip(*verts)
- xs,ys,zs = juggle_axes(xs,ys,zs,self.dir)
- vxs,vys,vzs,vis = proj3d.proj_transform_clip(xs,ys,zs, renderer.M)
- vverts.append((max(vzs),zip(vxs,vys)))
- vverts.sort()
- vverts.reverse()
- # mess with colors
- self._verts = [verts for (z,verts) in vverts]
- self.draw2d(renderer)
-
-class oLine3DCollection(LineCollection):
- def __init__(self, segments, *args, **kwargs):
- LineCollection.__init__(self, segments, *args, **kwargs)
- self.segments_3d = segments
-
- def draw(self, renderer):
- orig_segments = self._segments
- xyslist = [
- proj3d.proj_trans_points(points, renderer.M) for points in
- self.segments_3d]
- segments_2d = [zip(xs,ys) for (xs,ys,zs) in xyslist]
- self._segments = segments_2d
- LineCollection.draw(self, renderer)
- self._segments = orig_segments
-
-class Poly3DCollection(Wrap2D):
- def __init__(self, segments, *args, **kwargs):
- inst = PolyCollection(segments, *args, **kwargs)
- Wrap2D.__init__(self, inst)
- self._zsort = 1
- self.get_vector()
- self.remember('_facecolors')
- self.remember('_verts')
-
- def get_vector(self):
- """optimise points for projection"""
- si = 0
- ei = 0
- segis = []
- points = []
- for p in self._verts:
- points.extend(p)
- ei = si+len(p)
- segis.append((si,ei))
- si = ei
- xs,ys,zs = zip(*points)
- ones = np.ones(len(xs))
- self.vec = np.array([xs,ys,zs,ones])
- self.segis = segis
-
- def draw3d(self, renderer):
- #
- txs,tys,tzs,tis = proj3d.proj_transform_vec_clip(self.vec,renderer.M)
- xyslist = [(txs[si:ei],tys[si:ei],tzs[si:ei],tis[si:ei]) for si,ei in self.segis]
- colors = get_colors(self._facecolors, len(self._verts))
- #
- # if required sort by depth (furthest drawn first)
- if self._zsort:
- z_segments_2d = [(min(zs),max(tis),zip(xs,ys),c) for
- (xs,ys,zs,tis),c in zip(xyslist,colors)]
- z_segments_2d.sort()
- z_segments_2d.reverse()
- else:
- raise ValueError, "whoops"
- segments_2d = [s for z,i,s,c in z_segments_2d if i]
- colors = [c for z,i,s,c in z_segments_2d if i]
- self._verts = segments_2d
- self._facecolors = colors
-
- self.draw2d(renderer)
-
-def juggle_axes(xs,ys,zs, dir):
- """Depending on the direction of the plot re-order the axis
-
- This is so that 2d plots can be plotted along any direction.
- """
- if dir == 'x': return zs,xs,ys
- elif dir == 'y': return xs,zs,ys
- else: return xs,ys,zs
-
-class Line2DW(Wrap2D):
- def __init__(self, inst, z=0, dir='z'):
- Wrap2D.__init__(self, inst)
- self.z = z
- self.dir = dir
- self.remember('_x','_y')
-
- def draw3d(self, renderer):
- zs = [self.z for x in self._x]
- xs,ys,zs = juggle_axes(self._x,self._y,zs,self.dir)
- xs,ys,zs = proj3d.proj_transform(xs,ys,zs, renderer.M)
- self._x = xs
- self._y = ys
- self.draw2d(renderer)
-
-def line_draw(self, renderer):
- """Draw a 2D line as a 3D line"""
- oxs,oys = self.get_xdata(),self.get_ydata()
- xs,ys,zs = juggle_axes(oxs,oys,self.zs,self.dir)
- xs,ys,zs = proj3d.proj_transform(xs,ys,zs, renderer.M)
- self._x = xs
- self._y = ys
- self.old_draw(renderer)
- self._x = oxs
- self._y = oys
-
-def wrap_line(line, zs,dir='z'):
- """Wrap a 2D line so that it draws as a 3D line"""
- line.zs = zs
- line.dir = dir
- line.old_draw = line.draw
- def wrapped_draw(renderer,line=line):
- return line_draw(line,renderer)
- line.draw = wrapped_draw
-
-def image_draw(image,renderer):
- source = image._A
- w,h,p = source.shape
- X,Y = meshgrid(arange(w),arange(h))
- Z = np.zeros((w,h))
- tX,tY,tZ = proj3d.transform(X.flat,Y.flat,Z.flat,M)
- tX = reshape(tX,(w,h))
- tY = reshape(tY,(w,h))
-
-def wrap_image(image, extent):
- image.extent3D = extent
- image.old_draw = image.draw
- def wrapped_draw(renderer,image=image):
- return image_draw(image,renderer)
- image.draw = wrapped_draw
-
-
-def set_line_data(line, xs,ys,zs):
- try: line = line[0]
- except: pass
- line.set_data(xs,ys)
- line.zs = zs
-
-def iscolor(c):
- try:
- return (len(c)==4 or len(c)==3) and (type(c[0])==float)
- except (IndexError):
- return None
-
-def get_colors(c, num):
- """Stretch the color argument to provide the required number num"""
- if type(c)==type("string"):
- c = colors.colorConverter.to_rgba(colors)
- if iscolor(c):
- return [c]*num
- elif iscolor(c[0]):
- return c*num
- elif len(c)==num:
- return c[:]
- else:
- raise ValueError, 'unknown color format %s' % c
-
-def zalpha(colors, zs):
- """Modify the alphas of the color list according to depth"""
- colors = get_colors(colors,len(zs))
- norm = Normalize(min(zs),max(zs))
- sats = 1 - norm(zs)*0.7
- colors = [(c[0],c[1],c[2],c[3]*s) for c,s in zip(colors,sats)]
- return colors
-
-def patch_draw(self, renderer):
- orig_offsets = self._offsets
- xs,ys = zip(*self._offsets)
- xs,ys,zs = juggle_axes(xs,ys,self.zs,self.dir)
- xs,ys,zs = proj3d.proj_transform(xs,ys,zs, renderer.M)
- # mess with colors
- orig_fcolors = self._facecolors
- orig_ecolors = self._edgecolors
- self._facecolors = zalpha(orig_fcolors,zs)
- self._edgecolors = zalpha(orig_ecolors,zs)
-
- self._offsets = zip(xs,ys)
- self.old_draw(renderer)
- self._offsets = orig_offsets
- self._facecolors = orig_fcolors
- self._edgecolors = orig_ecolors
-
-def wrap_patch(patch, zs, dir='z'):
- return Patch3DCollectionW(patch, zs, dir)
-
-def draw_linec(self, renderer):
- orig_segments = self._segments
- segments_3d = [[(x,y,z) for (x,y),z in zip(points,zs)]
- for zs, points in zip(self.zs, self._segments)]
- xyslist = [
- proj3d.proj_trans_points(points, renderer.M) for points in
- segments_3d]
- segments_2d = [zip(xs,ys) for (xs,ys,zs) in xyslist]
- self._segments = segments_2d
- LineCollection.draw(self, renderer)
- self._segments = orig_segments
-
-def draw_polyc(self, renderer):
- orig_segments = self._verts
- # process the list of lists of 2D points held in _verts to generate
- # a list of lists of 3D points
- segments_3d = [[(x,y,z) for (x,y),z in zip(points,self.zs)]
- for points in self._verts]
- #
- xyslist = [
- proj3d.proj_trans_points(points, renderer.M) for points in
- segments_3d]
- segments_2d = [zip(xs,ys) for (xs,ys,zs) in xyslist]
- self._verts = segments_2d
- PolyCollection.draw(self, renderer)
- self._verts = orig_segments
-
-def text_draw(self, renderer):
- x,y = self.get_position()
- xs,ys,zs = juggle_axes(x,y,self._z,self.dir)
- xs,ys,zs = proj3d.proj_transform(xs,ys,zs, renderer.M)
- self.set_x(xs)
- self.set_y(ys)
- self.old_draw(renderer)
- self.set_x(x)
- self.set_y(y)
-
-def wrap_text(text, zs, dir='z'):
- text._z = zs
- text.dir = dir
- text.old_draw = text.draw
- def wrapped_draw(renderer,text=text):
- return text_draw(text,renderer)
- text.draw = wrapped_draw
-
-def set_text_data(text, x,y,z):
- text._x,text._y,text._z = x,y,z
-
-def draw(text, renderer):
- print 'call draw text', text
- print text.get_visible()
- print 'text "%s"' % text._text
- res = text._get_layout(renderer)
- print res
- text._draw(renderer)
-
-def owrap(text):
- text._draw = text.draw
- def draw_text(renderer,text=text):
- draw(text,renderer)
- text.draw = draw_text
-
-def wrap_2d_fn(patch, zs,dir='z',fn=patch_draw):
- patch.zs = zs
- patch.dir = dir
- patch.old_draw = patch.draw
- def wrapped_draw(renderer,patch=patch,fn=fn):
- return fn(patch,renderer)
- patch.draw = wrapped_draw
- return patch
Modified: trunk/matplotlib/lib/matplotlib/axes3d.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/axes3d.py 2008-06-22 08:19:56 UTC (rev 5628)
+++ trunk/matplotlib/lib/matplotlib/axes3d.py 2008-06-22 13:52:43 UTC (rev 5629)
@@ -1,835 +1 @@
-#!/usr/bin/python
-# axes3d.py
-#
-# Created: 23 Sep 2005
-#
-"""
-3D projection glued onto 2D Axes.
-
-Axes3D
-"""
-
-import random
-
-from axes import Axes
-import cbook
-from transforms import unit_bbox
-
-import numpy as np
-from colors import Normalize
-
-import art3d
-import proj3d
-import axis3d
-
-def sensible_format_data(self, value):
- """Used to generate more comprehensible numbers in status bar"""
- if abs(value) > 1e4 or abs(value)<1e-3:
- s = '%1.4e'% value
- return self._formatSciNotation(s)
- else:
- return '%4.3f' % value
-
-class Axes3DI(Axes):
- """Wrap an Axes object
-
- The x,y data coordinates, which are manipulated by set_xlim and
- set_ylim are used as the target view coordinates by the 3D
- transformations. These coordinates are mostly invisible to the
- outside world.
-
- set_w_xlim, set_w_ylim and set_w_zlim manipulate the 3D world
- coordinates which are scaled to represent the data and are stored
- in the xy_dataLim, zz_datalim bboxes.
-
- The axes representing the x,y,z world dimensions are self.w_xaxis,
- self.w_yaxis and self.w_zaxis. They can probably be controlled in
- more or less the normal ways.
- """
- def __init__(self, fig, rect=[0.0, 0.0, 1.0, 1.0], *args, **kwargs):
- self.fig = fig
-
- azim = cbook.popd(kwargs, 'azim', -60)
- elev = cbook.popd(kwargs, 'elev', 30)
-
- self.xy_viewLim = unit_bbox()
- self.zz_viewLim = unit_bbox()
- self.xy_dataLim = unit_bbox()
- self.zz_dataLim = unit_bbox()
- # inihibit autoscale_view until the axises are defined
- # they can't be defined until Axes.__init__ has been called
- self._ready = 0
- Axes.__init__(self, self.fig, rect,
- frameon=True,
- xticks=[], yticks=[], *args, **kwargs)
-
- self.M = None
- self._ready = 1
-
- self.view_init(elev, azim)
- self.mouse_init()
- self.create_axes()
- self.set_top_view()
-
- #self.axesPatch.set_edgecolor((1,0,0,0))
- self.axesPatch.set_linewidth(0)
- #self.axesPatch.set_facecolor((0,0,0,0))
- self.fig.add_axes(self)
-
- def set_top_view(self):
- # this happens to be the right view for the viewing coordinates
- # moved up and to the left slightly to fit labels and axes
- xdwl = (0.95/self.dist)
- xdw = (0.9/self.dist)
- ydwl = (0.95/self.dist)
- ydw = (0.9/self.dist)
- #
- self.set_xlim(-xdwl,xdw)
- self.set_ylim(-ydwl,ydw)
-
- def really_set_xlim(self, vmin, vmax):
- self.viewLim.intervalx().set_bounds(vmin, vmax)
-
- def really_set_ylim(self, vmin, vmax):
- self.viewLim.intervaly().set_bounds(vmin, vmax)
-
- def vlim_argument(self, get_lim, *args):
- if not args:
- vmin,vmax = get_lim()
- elif len(args)==2:
- vmin,vmax = args
- elif len(args)==1:
- vmin,vmax = args[0]
- return vmin,vmax
-
- def nset_xlim(self, *args):
- raise
- vmin,vmax = self.vlim_argument(self.get_xlim)
- print 'xlim', vmin,vmax
-
- def nset_ylim(self, *args):
- vmin,vmax = self.vlim_argument(self.get_ylim)
- print 'ylim', vmin,vmax
-
- def create_axes(self):
- self.w_xaxis = axis3d.Axis('x',self.xy_viewLim.intervalx,
- self.xy_dataLim.intervalx, self)
- self.w_yaxis = axis3d.Axis('y',self.xy_viewLim.intervaly,
- self.xy_dataLim.intervaly, self)
- self.w_zaxis = axis3d.Axis('z',self.zz_viewLim.intervalx,
- self.zz_dataLim.intervalx, self)
-
- def unit_cube(self,vals=None):
- minpy,maxx,miny,maxy,minz,maxz = vals or self.get_w_lims()
- xs,ys,zs = ([minpy,maxx,maxx,minpy,minpy,maxx,maxx,minpy],
- [miny,miny,maxy,maxy,miny,miny,maxy,maxy],
- [minz,minz,minz,minz,maxz,maxz,maxz,maxz])
- return zip(xs,ys,zs)
-
- def tunit_cube(self,vals=None,M=None):
- if M is None:
- M = self.M
- xyzs = self.unit_cube(vals)
- tcube = proj3d.proj_points(xyzs,M)
- return tcube
-
- def tunit_edges(self, vals=None,M=None):
- tc = self.tunit_cube(vals,M)
- edges = [(tc[0],tc[1]),
- (tc[1],tc[2]),
- (tc[2],tc[3]),
- (tc[3],tc[0]),
-
- (tc[0],tc[4]),
- (tc[1],tc[5]),
- (tc[2],tc[6]),
- (tc[3],tc[7]),
-
- (tc[4],tc[5]),
- (tc[5],tc[6]),
- (tc[6],tc[7]),
- (tc[7],tc[4])]
- return edges
-
- def draw(self, renderer):
- # draw the background patch
- self.axesPatch.draw(renderer)
- self._frameon = False
-
- # add the projection matrix to the renderer
- self.M = self.get_proj()
- renderer.M = self.M
- renderer.vvec = self.vvec
- renderer.eye = self.eye
- renderer.get_axis_position = self.get_axis_position
-
- #self.set_top_view()
- self.w_xaxis.draw(renderer)
- self.w_yaxis.draw(renderer)
- self.w_zaxis.draw(renderer)
- Axes.draw(self, renderer)
-
- def get_axis_position(self):
- vals = self.get_w_lims()
- tc = self.tunit_cube(vals,self.M)
- xhigh = tc[1][2]>tc[2][2]
- yhigh = tc[3][2]>tc[2][2]
- zhigh = tc[0][2]>tc[2][2]
- return xhigh,yhigh,zhigh
-
- def update_datalim(self, xys):
- pass
-
- def update_datalim_numerix(self, x, y):
- pass
-
- def auto_scale_xyz(self, X,Y,Z=None,had_data=None):
- x,y,z = map(np.asarray, (X,Y,Z))
- try:
- x,y = X.flat,Y.flat
- if Z is not None:
- z = Z.flat
- except AttributeError:
- pass
-
- self.xy_dataLim.update_numerix(x, y, not had_data)
- if z is not None:
- self.zz_dataLim.update_numerix(z, z, not had_data)
- self.autoscale_view()
-
- def autoscale_view(self, scalex=True, scaley=True, scalez=True):
- self.set_top_view()
- if not self._ready: return
-
- if not self._autoscaleon: return
-
- if scalex:
- locator = self.w_xaxis.get_major_locator()
- self.set_w_xlim(locator.autoscale())
- if scaley:
- locator = self.w_yaxis.get_major_locator()
- self.set_w_ylim(locator.autoscale())
- if scalez:
- locator = self.w_zaxis.get_major_locator()
- self.set_w_zlim(locator.autoscale())
-
- def get_w_lims(self):
- minpy,maxx = self.get_w_xlim()
- miny,maxy = self.get_w_ylim()
- minz,maxz = self.get_w_zlim()
- return minpy,maxx,miny,maxy,minz,maxz
-
- def set_w_zlim(self, *args, **kwargs):
- gl,self.get_xlim = self.get_xlim,self.get_w_zlim
- vl,self.viewLim = self.viewLim,self.zz_vi...
[truncated message content] |
|
From: <jd...@us...> - 2008-06-22 15:08:12
|
Revision: 5630
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5630&view=rev
Author: jdh2358
Date: 2008-06-22 08:08:05 -0700 (Sun, 22 Jun 2008)
Log Message:
-----------
removed axes3d; fixed an alpha bug on backend draw collections
Modified Paths:
--------------
trunk/matplotlib/examples/pylab_examples/scatter_demo2.py
trunk/matplotlib/lib/matplotlib/backend_bases.py
Modified: trunk/matplotlib/examples/pylab_examples/scatter_demo2.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/scatter_demo2.py 2008-06-22 13:52:43 UTC (rev 5629)
+++ trunk/matplotlib/examples/pylab_examples/scatter_demo2.py 2008-06-22 15:08:05 UTC (rev 5630)
@@ -15,7 +15,7 @@
ylabel(r'$\Delta_{i+1}$', size='x-large')
title(r'Volume and percent change')
grid(True)
-#savefig('scatter_demo2')
+savefig('scatter_demo2')
colorbar()
show()
Modified: trunk/matplotlib/lib/matplotlib/backend_bases.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backend_bases.py 2008-06-22 13:52:43 UTC (rev 5629)
+++ trunk/matplotlib/lib/matplotlib/backend_bases.py 2008-06-22 15:08:05 UTC (rev 5630)
@@ -262,6 +262,9 @@
gc.set_linewidth(linewidths[i % Nlinewidths])
if Nlinestyles:
gc.set_dashes(*linestyles[i % Nlinestyles])
+ if len(rgbFace)==4:
+ gc.set_alpha(rgbFace[-1])
+ rgbFace = rgbFace[:3]
gc.set_antialiased(antialiaseds[i % Naa])
yield xo, yo, path_id, gc, rgbFace
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2008-06-22 16:24:12
|
Revision: 5633
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5633&view=rev
Author: jdh2358
Date: 2008-06-22 09:24:02 -0700 (Sun, 22 Jun 2008)
Log Message:
-----------
Merged revisions 5604,5625,5631 via svnmerge from
https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/branches/v0_91_maint
........
r5604 | efiring | 2008-06-19 23:53:28 -0500 (Thu, 19 Jun 2008) | 2 lines
Don't try to render a line collection with no segments
........
r5625 | dsdale | 2008-06-21 08:35:30 -0500 (Sat, 21 Jun 2008) | 2 lines
improve mlab.load docstring to address bug 1901536
........
r5631 | jdh2358 | 2008-06-22 11:15:24 -0500 (Sun, 22 Jun 2008) | 1 line
changed wx backend to respect extension over gui dialog default type
........
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-5573,5603
+ /branches/v0_91_maint:1-5632
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_wx.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_wx.py 2008-06-22 16:16:20 UTC (rev 5632)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_wx.py 2008-06-22 16:24:02 UTC (rev 5633)
@@ -94,6 +94,7 @@
cvs_id = '$Id$'
+
import sys, os, os.path, math, StringIO, weakref, warnings
# Debugging settings here...
@@ -1646,8 +1647,14 @@
filename = dlg.GetFilename()
DEBUG_MSG('Save file dir:%s name:%s' % (dirname, filename), 3, self)
format = exts[dlg.GetFilterIndex()]
- # Explicitly pass in the selected filetype to override the
- # actual extension if necessary
+ basename, ext = os.path.splitext(filename)
+ if ext.startswith('.'):
+ ext = ext[1:]
+ if ext in ('svg', 'pdf', 'ps', 'eps', 'png') and format!=ext:
+ #looks like they forgot to set the image type drop
+ #down, going with the extension.
+ warnings.warn('extension %s did not match the selected image type %s; going with %s'%(ext, format, ext), stacklevel=0)
+ format = ext
try:
self.canvas.print_figure(
os.path.join(dirname, filename), format=format)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2008-06-23 12:35:16
|
Revision: 5641
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5641&view=rev
Author: mdboom
Date: 2008-06-23 05:34:45 -0700 (Mon, 23 Jun 2008)
Log Message:
-----------
Use splines to render circles in scatter plots.
Modified Paths:
--------------
trunk/matplotlib/CHANGELOG
trunk/matplotlib/lib/matplotlib/axes.py
trunk/matplotlib/lib/matplotlib/collections.py
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2008-06-23 12:10:31 UTC (rev 5640)
+++ trunk/matplotlib/CHANGELOG 2008-06-23 12:34:45 UTC (rev 5641)
@@ -1,3 +1,5 @@
+2008-06-23 Use splines to render circles in scatter plots - MGD
+
===============================================================
2008-06-22 Released 0.98.1 at revision 5637
Modified: trunk/matplotlib/lib/matplotlib/axes.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/axes.py 2008-06-23 12:10:31 UTC (rev 5640)
+++ trunk/matplotlib/lib/matplotlib/axes.py 2008-06-23 12:34:45 UTC (rev 5641)
@@ -4561,22 +4561,23 @@
The marker can also be a tuple (*numsides*, *style*,
*angle*), which will create a custom, regular symbol.
- *numsides*:
- the number of sides
+ *numsides*:
+ the number of sides
- *style*:
- the style of the regular symbol:
+ *style*:
+ the style of the regular symbol:
- ===== ==================
- Value Description
- ===== ==================
- 0 a regular polygon
- 1 a star-like symbol
- 2 an asterisk
- ===== ==================
+ ===== ==================
+ Value Description
+ ===== =========================================
+ 0 a regular polygon
+ 1 a star-like symbol
+ 2 an asterisk
+ 3 a circle (numsides and angle is ignored)
+ ===== =========================================
- *angle*:
- the angle of rotation of the symbol
+ *angle*:
+ the angle of rotation of the symbol
Finally, *marker* can be (*verts*, 0): *verts* is a
sequence of (*x*, *y*) vertices for a custom scatter
@@ -4640,7 +4641,7 @@
syms = { # a dict from symbol to (numsides, angle)
's' : (4,math.pi/4.0,0), # square
- 'o' : (20,0,0), # circle
+ 'o' : (20,3,0), # circle
'^' : (3,0,0), # triangle up
'>' : (3,math.pi/2.0,0), # triangle right
'v' : (3,math.pi,0), # triangle down
@@ -4748,9 +4749,16 @@
offsets = zip(x,y),
transOffset = self.transData,
)
+ elif symstyle==3:
+ collection = mcoll.CircleCollection(
+ scales,
+ facecolors = colors,
+ edgecolors = edgecolors,
+ linewidths = linewidths,
+ offsets = zip(x,y),
+ transOffset = self.transData,
+ )
else:
- # MGDTODO: This has dpi problems
- # rescale verts
rescale = np.sqrt(max(verts[:,0]**2+verts[:,1]**2))
verts /= rescale
Modified: trunk/matplotlib/lib/matplotlib/collections.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/collections.py 2008-06-23 12:10:31 UTC (rev 5640)
+++ trunk/matplotlib/lib/matplotlib/collections.py 2008-06-23 12:34:45 UTC (rev 5641)
@@ -805,6 +805,32 @@
return self._edgecolors
get_colors = get_color # for compatibility with old versions
+class CircleCollection(Collection):
+ """
+ A collection of circles, drawn using splines.
+ """
+ def __init__(self, sizes):
+ """
+ *sizes*
+ Gives the area of the circle in points^2
+
+ %(Collection)s
+ """
+ Collection.__init__(self,**kwargs)
+ self._sizes = sizes
+ self.set_transform(transforms.IdentityTransform())
+ self._paths = [mpath.Path.unit_circle()]
+
+ def draw(self, renderer):
+ # sizes is the area of the circle circumscribing the polygon
+ # in points^2
+ self._transforms = [
+ transforms.Affine2D().scale(
+ (np.sqrt(x) * renderer.dpi / 72.0) / np.sqrt(np.pi))
+ for x in self._sizes]
+ return Collection.draw(self, renderer)
+
+
class PatchCollection(Collection):
"""
A generic collection of patches.
@@ -870,6 +896,6 @@
artist.kwdocd['Collection'] = patchstr = artist.kwdoc(Collection)
for k in ('QuadMesh', 'PolyCollection', 'BrokenBarHCollection', 'RegularPolyCollection',
- 'StarPolygonCollection'):
+ 'StarPolygonCollection', 'PatchCollection', 'CircleCollection'):
artist.kwdocd[k] = patchstr
artist.kwdocd['LineCollection'] = artist.kwdoc(LineCollection)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ds...@us...> - 2008-06-23 15:51:13
|
Revision: 5648
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5648&view=rev
Author: dsdale
Date: 2008-06-23 08:49:03 -0700 (Mon, 23 Jun 2008)
Log Message:
-----------
converted afm docstrings
Modified Paths:
--------------
trunk/matplotlib/doc/api/index.rst
trunk/matplotlib/doc/devel/outline.rst
trunk/matplotlib/lib/matplotlib/afm.py
Added Paths:
-----------
trunk/matplotlib/doc/api/afm_api.rst
Added: trunk/matplotlib/doc/api/afm_api.rst
===================================================================
--- trunk/matplotlib/doc/api/afm_api.rst (rev 0)
+++ trunk/matplotlib/doc/api/afm_api.rst 2008-06-23 15:49:03 UTC (rev 5648)
@@ -0,0 +1,12 @@
+**************
+matplotlib afm
+**************
+
+
+:mod:`matplotlib.afm`
+=====================
+
+.. automodule:: matplotlib.afm
+ :members:
+ :undoc-members:
+ :show-inheritance:
Modified: trunk/matplotlib/doc/api/index.rst
===================================================================
--- trunk/matplotlib/doc/api/index.rst 2008-06-23 15:26:52 UTC (rev 5647)
+++ trunk/matplotlib/doc/api/index.rst 2008-06-23 15:49:03 UTC (rev 5648)
@@ -12,6 +12,7 @@
.. toctree::
matplotlib_configuration_api.rst
+ afm_api.rst
artist_api.rst
figure_api.rst
axes_api.rst
Modified: trunk/matplotlib/doc/devel/outline.rst
===================================================================
--- trunk/matplotlib/doc/devel/outline.rst 2008-06-23 15:26:52 UTC (rev 5647)
+++ trunk/matplotlib/doc/devel/outline.rst 2008-06-23 15:49:03 UTC (rev 5648)
@@ -111,7 +111,7 @@
projections/__init__ needs conversion
projections/geo needs conversion
projections/polar needs conversion
-afm needs conversion
+afm converted
artist needs conversion
axes needs conversion
axis needs conversion
Modified: trunk/matplotlib/lib/matplotlib/afm.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/afm.py 2008-06-23 15:26:52 UTC (rev 5647)
+++ trunk/matplotlib/lib/matplotlib/afm.py 2008-06-23 15:49:03 UTC (rev 5648)
@@ -11,7 +11,7 @@
3) Did more than I needed and it was easier to write my own than
figure out how to just get what I needed from theirs
-It is pretty easy to use, and requires only built-in python libs
+It is pretty easy to use, and requires only built-in python libs:
>>> from afm import AFM
>>> fh = file('ptmr8a.afm')
@@ -31,7 +31,7 @@
AUTHOR:
- John D. Hunter <jdh...@ac...>
+ John D. Hunter <jd...@gm...>
"""
import sys, os
@@ -56,7 +56,7 @@
def _sanity_check(fh):
"""
Check if the file at least looks like AFM.
- If not, raise RuntimeError.
+ If not, raise :exc:`RuntimeError`.
"""
# Remember the file position in case the caller wants to
@@ -77,10 +77,13 @@
def _parse_header(fh):
"""
Reads the font metrics header (up to the char metrics) and returns
- a dictionary mapping key to val. val will be converted to the
- appropriate python type as necessary; eg 'False'->False, '0'->0,
- '-168 -218 1000 898'-> [-168, -218, 1000, 898]
+ a dictionary mapping *key* to *val*. *val* will be converted to the
+ appropriate python type as necessary; eg:
+ * 'False'->False
+ * '0'->0
+ * '-168 -218 1000 898'-> [-168, -218, 1000, 898]
+
Dictionary keys are
StartFontMetrics, FontName, FullName, FamilyName, Weight,
@@ -142,14 +145,12 @@
def _parse_char_metrics(fh):
"""
Return a character metric dictionary. Keys are the ASCII num of
- the character, values are a (wx, name, bbox) tuple, where
+ the character, values are a (*wx*, *name*, *bbox*) tuple, where
+ *wx* is the character width, *name* is the postscript language
+ name, and *bbox* is a (*llx*, *lly*, *urx*, *ury*) tuple.
- wx is the character width
- name is the postscript language name
- bbox (llx, lly, urx, ury)
-
- This function is incomplete per the standard, but thus far parse
- all the sample afm files I have
+ This function is incomplete per the standard, but thus far parses
+ all the sample afm files tried.
"""
ascii_d = {}
@@ -176,13 +177,12 @@
def _parse_kern_pairs(fh):
"""
- Return a kern pairs dictionary; keys are (char1, char2) tuples and
+ Return a kern pairs dictionary; keys are (*char1*, *char2*) tuples and
values are the kern pair value. For example, a kern pairs line like
+ ``KPX A y -50``
- KPX A y -50
+ will be represented as::
- will be represented as
-
d[ ('A', 'y') ] = -50
"""
@@ -210,13 +210,13 @@
def _parse_composites(fh):
"""
Return a composites dictionary. Keys are the names of the
- composites. vals are a num parts list of composite information,
- with each element being a (name, dx, dy) tuple. Thus if a
+ composites. Values are a num parts list of composite information,
+ with each element being a (*name*, *dx*, *dy*) tuple. Thus a
composites line reading:
CC Aacute 2 ; PCC A 0 0 ; PCC acute 160 170 ;
- will be represented as
+ will be represented as::
d['Aacute'] = [ ('A', 0, 0), ('acute', 160, 170) ]
@@ -245,9 +245,10 @@
"""
Parse the optional fields for kern pair data and composites
- return value is a kernDict, compositeDict which are the return
- values from parse_kern_pairs, and parse_composites if the data
- exists, or empty dicts otherwise
+ return value is a (*kernDict*, *compositeDict*) which are the
+ return values from :func:`_parse_kern_pairs`, and
+ :func:`_parse_composites` if the data exists, or empty dicts
+ otherwise
"""
optional = {
'StartKernData' : _parse_kern_pairs,
@@ -269,13 +270,12 @@
def parse_afm(fh):
"""
- Parse the Adobe Font Metics file in file handle fh
- Return value is a (dhead, dcmetrics, dkernpairs, dcomposite) tuple where
-
- dhead : a parse_header dict
- dcmetrics : a parse_composites dict
- dkernpairs : a parse_kern_pairs dict, possibly {}
- dcomposite : a parse_composites dict , possibly {}
+ Parse the Adobe Font Metics file in file handle *fh*. Return value
+ is a (*dhead*, *dcmetrics*, *dkernpairs*, *dcomposite*) tuple where
+ *dhead* is a :func:`_parse_header` dict, *dcmetrics* is a
+ :func:`_parse_composites` dict, *dkernpairs* is a
+ :func:`_parse_kern_pairs` dict (possibly {}), and *dcomposite* is a
+ :func:`_parse_composites` dict (possibly {})
"""
_sanity_check(fh)
dhead = _parse_header(fh)
@@ -288,7 +288,7 @@
def __init__(self, fh):
"""
- Parse the AFM file in file object fh
+ Parse the AFM file in file object *fh*
"""
(dhead, dcmetrics_ascii, dcmetrics_name, dkernpairs, dcomposite) = \
parse_afm(fh)
@@ -307,7 +307,7 @@
def string_width_height(self, s):
"""
Return the string width (including kerning) and string height
- as a w,h tuple
+ as a (*w*, *h*) tuple.
"""
if not len(s): return 0,0
totalw = 0
@@ -404,8 +404,8 @@
def get_height_char(self, c, isord=False):
"""
- Get the height of character c from the bounding box. This is
- the ink height (space is 0)
+ Get the height of character *c* from the bounding box. This
+ is the ink height (space is 0)
"""
if not isord: c=ord(c)
wx, name, bbox = self._metrics[c]
@@ -413,30 +413,30 @@
def get_kern_dist(self, c1, c2):
"""
- Return the kerning pair distance (possibly 0) for chars c1 and
- c2
+ Return the kerning pair distance (possibly 0) for chars *c1*
+ and *c2*
"""
name1, name2 = self.get_name_char(c1), self.get_name_char(c2)
return self.get_kern_dist_from_name(name1, name2)
def get_kern_dist_from_name(self, name1, name2):
"""
- Return the kerning pair distance (possibly 0) for chars c1 and
- c2
+ Return the kerning pair distance (possibly 0) for chars
+ *name1* and *name2*
"""
try: return self._kern[ (name1, name2) ]
except: return 0
def get_fontname(self):
- "Return the font name, eg, Times-Roman"
+ "Return the font name, eg, 'Times-Roman'"
return self._header['FontName']
def get_fullname(self):
- "Return the font full name, eg, Times-Roman"
+ "Return the font full name, eg, 'Times-Roman'"
return self._header['FullName']
def get_familyname(self):
- "Return the font family name, eg, Times"
+ "Return the font family name, eg, 'Times'"
return self._header['FamilyName']
def get_weight(self):
@@ -461,14 +461,14 @@
def get_horizontal_stem_width(self):
"""
- Return the standard horizontal stem width as float, or None if
+ Return the standard horizontal stem width as float, or *None* if
not specified in AFM file.
"""
return self._header.get('StdHW', None)
def get_vertical_stem_width(self):
"""
- Return the standard vertical stem width as float, or None if
+ Return the standard vertical stem width as float, or *None* if
not specified in AFM file.
"""
return self._header.get('StdVW', None)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ds...@us...> - 2008-06-23 16:17:41
|
Revision: 5649
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5649&view=rev
Author: dsdale
Date: 2008-06-23 09:16:24 -0700 (Mon, 23 Jun 2008)
Log Message:
-----------
artist docstring conversion
Modified Paths:
--------------
trunk/matplotlib/doc/devel/outline.rst
trunk/matplotlib/lib/matplotlib/artist.py
Modified: trunk/matplotlib/doc/devel/outline.rst
===================================================================
--- trunk/matplotlib/doc/devel/outline.rst 2008-06-23 15:49:03 UTC (rev 5648)
+++ trunk/matplotlib/doc/devel/outline.rst 2008-06-23 16:16:24 UTC (rev 5649)
@@ -112,7 +112,7 @@
projections/geo needs conversion
projections/polar needs conversion
afm converted
-artist needs conversion
+artist converted
axes needs conversion
axis needs conversion
backend_bases needs conversion
Modified: trunk/matplotlib/lib/matplotlib/artist.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/artist.py 2008-06-23 15:49:03 UTC (rev 5648)
+++ trunk/matplotlib/lib/matplotlib/artist.py 2008-06-23 16:16:24 UTC (rev 5649)
@@ -81,7 +81,7 @@
# TODO: add legend support
def have_units(self):
- 'return True if units are set on the x or y axes'
+ 'return *True* if units are set on the x or y axes'
ax = self.axes
if ax is None or ax.xaxis is None:
return False
@@ -89,7 +89,7 @@
def convert_xunits(self, x):
"""for artists in an axes, if the xaxis as units support,
- convert x using xaxis unit type
+ convert *x* using xaxis unit type
"""
ax = getattr(self, 'axes', None)
if ax is None or ax.xaxis is None:
@@ -99,7 +99,7 @@
def convert_yunits(self, y):
"""for artists in an axes, if the yaxis as units support,
- convert y using yaxis unit type
+ convert *y* using yaxis unit type
"""
ax = getattr(self, 'axes', None)
if ax is None or ax.yaxis is None: return y
@@ -107,14 +107,14 @@
def set_axes(self, axes):
"""
- set the axes instance the artist resides in, if any
+ set the axes instance in which the artist resides, if any
ACCEPTS: an axes instance
"""
self.axes = axes
def get_axes(self):
- 'return the axes instance the artist resides in, or None'
+ 'return the axes instance the artist resides in, or *None*'
return self.axes
def add_callback(self, func):
@@ -170,7 +170,7 @@
for a in self.get_children(): L.extend(a.hitlist(event))
return L
- def contains(self,mouseevent):
+ def contains(self, mouseevent):
"""Test whether the artist contains the mouse event.
Returns the truth value and a dictionary of artist specific details of
@@ -189,26 +189,28 @@
hit, props = picker(artist, mouseevent)
- If the mouse event is over the artist, return hit=True and props
+ If the mouse event is over the artist, return *hit=True* and *props*
is a dictionary of properties you want returned with the contains test.
"""
self._contains = picker
def get_contains(self):
- 'return the _contains test used by the artist, or None for default.'
+ 'return the _contains test used by the artist, or *None* for default.'
return self._contains
def pickable(self):
- 'return True if self is pickable'
+ 'return *True* if self is pickable'
return (self.figure is not None and
self.figure.canvas is not None and
self._picker is not None)
def pick(self, mouseevent):
"""
- pick(mouseevent)
+ call signature::
- each child artist will fire a pick event if mouseevent is over
+ pick(mouseevent)
+
+ each child artist will fire a pick event if *mouseevent* is over
the artist and the artist has picker set
"""
# Pick self
@@ -229,31 +231,31 @@
"""
set the epsilon for picking used by this artist
- picker can be one of the following:
+ *picker* can be one of the following:
- None - picking is disabled for this artist (default)
+ * *None*: picking is disabled for this artist (default)
- boolean - if True then picking will be enabled and the
- artist will fire a pick event if the mouse event is over
- the artist
+ * A boolean: if *True* then picking will be enabled and the
+ artist will fire a pick event if the mouse event is over
+ the artist
- float - if picker is a number it is interpreted as an
- epsilon tolerance in points and the the artist will fire
- off an event if it's data is within epsilon of the mouse
- event. For some artists like lines and patch collections,
- the artist may provide additional data to the pick event
- that is generated, eg the indices of the data within
- epsilon of the pick event
+ * A float: if picker is a number it is interpreted as an
+ epsilon tolerance in points and the artist will fire
+ off an event if it's data is within epsilon of the mouse
+ event. For some artists like lines and patch collections,
+ the artist may provide additional data to the pick event
+ that is generated, e.g. the indices of the data within
+ epsilon of the pick event
- function - if picker is callable, it is a user supplied
- function which determines whether the artist is hit by the
- mouse event::
+ * A function: if picker is callable, it is a user supplied
+ function which determines whether the artist is hit by the
+ mouse event::
hit, props = picker(artist, mouseevent)
- to determine the hit test. if the mouse event is over the
- artist, return hit=True and props is a dictionary of
- properties you want added to the PickEvent attributes.
+ to determine the hit test. if the mouse event is over the
+ artist, return *hit=True* and props is a dictionary of
+ properties you want added to the PickEvent attributes.
ACCEPTS: [None|float|boolean|callable]
"""
@@ -263,7 +265,6 @@
'return the Pickeration instance used by this artist'
return self._picker
-
def is_figure_set(self):
return self.figure is not None
@@ -279,7 +280,7 @@
Set the :class:`~matplotlib.figure.Figure` instance the artist
belongs to.
- ACCEPTS: a matplotlib.figure.Figure instance
+ ACCEPTS: a :class:`matplotlib.figure.Figure` instance
"""
self.figure = fig
self.pchanged()
@@ -288,7 +289,7 @@
"""
Set the artist's clip Bbox
- ACCEPTS: a matplotlib.transform.Bbox instance
+ ACCEPTS: a :class:`matplotlib.transform.Bbox` instance
"""
self.clipbox = clipbox
self._clipon = clipbox is not None or self._clippath is not None
@@ -298,21 +299,22 @@
"""
Set the artist's clip path, which may be:
- a) a :class:`~matplotlib.patches.Patch` (or subclass) instance
+ * a :class:`~matplotlib.patches.Patch` (or subclass) instance
- b) a :class:`~matplotlib.path.Path` instance, in which case
+ * a :class:`~matplotlib.path.Path` instance, in which case
an optional :class:`~matplotlib.transforms.Transform`
instance may be provided, which will be applied to the
path before using it for clipping.
- c) *None*, to remove the clipping path
+ * *None*, to remove the clipping path
For efficiency, if the path happens to be an axis-aligned
rectangle, this method will set the clipping box to the
corresponding rectangle and set the clipping path to *None*.
- ACCEPTS: a Path instance and a Transform instance, a Patch
- instance, or None
+ ACCEPTS: a :class:`~matplotlib.path.Path` instance and a
+ :class:`~matplotlib.transforms.Transform` instance, a
+ :class:`~matplotlib.patches.Patch` instance, or *None*.
"""
from patches import Patch, Rectangle
@@ -371,8 +373,9 @@
def get_transformed_clip_path_and_affine(self):
'''
- Return the clip path with the non-affine part of its transformation applied,
- and the remaining affine part of its transformation.
+ Return the clip path with the non-affine part of its
+ transformation applied, and the remaining affine part of its
+ transformation.
'''
if self._clippath is not None:
return self._clippath.get_transformed_path_and_affine()
@@ -459,7 +462,7 @@
def set_label(self, s):
"""
- Set the line label to s for auto legend
+ Set the line label to *s* for auto legend
ACCEPTS: any string
"""
@@ -495,7 +498,7 @@
def set(self, **kwargs):
"""
- A tkstyle set command, pass kwargs to set properties
+ A tkstyle set command, pass *kwargs* to set properties
"""
ret = []
for k,v in kwargs.items():
@@ -526,8 +529,8 @@
def get_aliases(self):
"""
- Get a dict mapping *fullname* -> *alias* for each alias in the
- :class:`~matplotlib.artist.ArtistInspector`.
+ Get a dict mapping *fullname* -> *alias* for each *alias* in
+ the :class:`~matplotlib.artist.ArtistInspector`.
Eg., for lines::
@@ -553,7 +556,7 @@
"""
Get the legal arguments for the setter associated with *attr*.
- This is done by querying the docstring of the function set_ *attr*
+ This is done by querying the docstring of the function *set_attr*
for a line that begins with ACCEPTS:
Eg., for a line linestyle, return
@@ -603,11 +606,11 @@
def aliased_name(self, s):
"""
- return 'PROPNAME or alias' if s has an alias, else return
+ return 'PROPNAME or alias' if *s* has an alias, else return
PROPNAME.
- Eg for the line markerfacecolor property, which has an alias,
- return 'markerfacecolor or mfc' and for the transform
+ E.g. for the line markerfacecolor property, which has an
+ alias, return 'markerfacecolor or mfc' and for the transform
property, which does not, return 'transform'
"""
if self.aliasd.has_key(s):
@@ -701,11 +704,11 @@
getp can be used to query all the gettable properties with getp(o)
Many properties have aliases for shorter typing, eg 'lw' is an
alias for 'linewidth'. In the output, aliases and full property
- names will be listed as
+ names will be listed as:
property or alias = value
- eg
+ e.g.:
linewidth or lw = 2
"""
@@ -750,7 +753,7 @@
:func:`setp` operates on a single instance or a list of instances.
If you are in query mode introspecting the possible values, only
the first instance in the sequence is used. When actually setting
- values, all the instances will be set. Eg., suppose you have a
+ values, all the instances will be set. E.g., suppose you have a
list of two lines, the following will make both lines thicker and
red::
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ds...@us...> - 2008-06-23 17:46:52
|
Revision: 5650
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5650&view=rev
Author: dsdale
Date: 2008-06-23 10:46:26 -0700 (Mon, 23 Jun 2008)
Log Message:
-----------
finish converting axes docstrings
Modified Paths:
--------------
trunk/matplotlib/doc/devel/outline.rst
trunk/matplotlib/lib/matplotlib/axes.py
Modified: trunk/matplotlib/doc/devel/outline.rst
===================================================================
--- trunk/matplotlib/doc/devel/outline.rst 2008-06-23 16:16:24 UTC (rev 5649)
+++ trunk/matplotlib/doc/devel/outline.rst 2008-06-23 17:46:26 UTC (rev 5650)
@@ -113,7 +113,7 @@
projections/polar needs conversion
afm converted
artist converted
-axes needs conversion
+axes converted
axis needs conversion
backend_bases needs conversion
cbook needs conversion
Modified: trunk/matplotlib/lib/matplotlib/axes.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/axes.py 2008-06-23 16:16:24 UTC (rev 5649)
+++ trunk/matplotlib/lib/matplotlib/axes.py 2008-06-23 17:46:26 UTC (rev 5650)
@@ -69,15 +69,16 @@
def _process_plot_format(fmt):
"""
Process a matlab(TM) style color/line style format string. Return a
- linestyle, color tuple as a result of the processing. Default
+ (*linestyle*, *color*) tuple as a result of the processing. Default
values are ('-', 'b'). Example format strings include:
* 'ko': black circles
* '.b': blue dots
* 'r--': red dashed lines
- See Line2D.lineStyles and GraphicsContext.colors for all possible
- styles and color format string.
+ See :func:`~matplotlib.Line2D.lineStyles` and
+ :func:`~matplotlib.pyplot.colors` for all possible styles and
+ color format string.
"""
@@ -138,10 +139,11 @@
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.
+ command. This must be called before creating the
+ :class:`Axes` to which it will apply; it will
+ apply to all future axes.
- clist is a sequence of mpl color specifiers
+ *clist* is a sequence of mpl color specifiers
"""
_process_plot_var_args.defaultColors = clist[:]
@@ -158,7 +160,7 @@
plot(t1, s1, 'ko', t2, s2)
plot(t1, s1, 'ko', t2, s2, 'r--', t3, e3)
- an arbitrary number of x, y, fmt are allowed
+ an arbitrary number of *x*, *y*, *fmt* are allowed
"""
defaultColors = ['b','g','r','c','m','y','k']
@@ -444,13 +446,17 @@
class Axes(martist.Artist):
"""
- The Axes contains most of the figure elements: Axis, Tick, Line2D,
- Text, Polygon etc, and sets the coordinate system
+ The :class:`Axes` contains most of the figure elements:
+ :class:`~matplotlib.axis.Axis`, :class:`~matplotlib.axis.Tick`,
+ :class:`~matplotlib.lines.Line2D`, :class:`~matplotlib.text.Text`,
+ :class:`~matplotlib.patches.Polygon`, etc., and sets the
+ coordinate system.
- The Axes instance supports callbacks through a callbacks attribute
- which is a cbook.CallbackRegistry instance. The events you can
- connect to are 'xlim_changed' and 'ylim_changed' and the callback
- will be called with func(ax) where ax is the Axes instance
+ The :class:`Axes` instance supports callbacks through a callbacks attribute
+ which is a :class:`~matplotlib.cbook.CallbackRegistry` instance.
+ The events you can connect to are :meth:`xlim_changed` and
+ :meth:`ylim_changed` and the callback will be called with
+ func(*ax() where *ax* is the :class:`Axes` instance.
"""
name = "rectilinear"
@@ -469,45 +475,55 @@
**kwargs
):
"""
- Build an Axes instance in Figure fig with
- rect=[left, bottom, width, height] in Figure coords
+ Build an :class:`Axes` instance in
+ :class:`~matplotlib.figure.Figure` *fig* with
+ *rect=[left, bottom, width, height]* in
+ :class:`~matplotlib.figure.Figure` coordinates
Optional keyword arguments:
- ============== ====================================================
- Keyword Description
- ============== ====================================================
- adjustable [ 'box' | 'datalim' ]
- alpha float: the alpha transparency
- anchor [ 'C', 'SW', 'S', 'SE', 'E', 'NE', 'N', 'NW', 'W' ]
- aspect [ 'auto' | 'equal' | aspect_ratio ]
- autoscale_on [ True | False ] whether or not to autoscale the
- viewlim
- axis_bgcolor any matplotlib color - see help(colors)
- axisbelow draw the grids and ticks below the other artists
- cursor_props a (float, color) tuple
- figure a Figure instance
- frame_on a boolean - draw the axes frame
- label the axes label
- navigate [ True | False ]
- navigate_mode [ 'PAN' | 'ZOOM' | None ] the navigation toolbar
- button status
- position [left, bottom, width, height] in Figure coords
- sharex an Axes instance to share the x-axis with
- sharey an Axes instance to share the y-axis with
- title the title string
- visible [ True | False ] whether the axes is visible
- xlabel the xlabel
- xlim (xmin, xmax) view limits
- xscale [%(scale)s]
- xticklabels sequence of strings
- xticks sequence of floats
- ylabel the ylabel strings
- ylim (ymin, ymax) view limits
- yscale [%(scale)s]
- yticklabels sequence of strings
- yticks sequence of floats
- ============== ====================================================
+ ================ =========================================
+ Keyword Description
+ ================ =========================================
+ *adjustable* [ 'box' | 'datalim' ]
+ *alpha* float: the alpha transparency
+ *anchor* [ 'C', 'SW', 'S', 'SE', 'E', 'NE', 'N',
+ 'NW', 'W' ]
+ *aspect* [ 'auto' | 'equal' | aspect_ratio ]
+ *autoscale_on* [ *True* | *False* ] whether or not to
+ autoscale the *viewlim*
+ *axis_bgcolor* any matplotlib color, see
+ :func:`~matplotlib.pyplot.colors`
+ *axisbelow* draw the grids and ticks below the other
+ artists
+ *cursor_props* a (*float*, *color*) tuple
+ *figure* a :class:`~matplotlib.figure.Figure`
+ instance
+ *frame_on* a boolean - draw the axes frame
+ *label* the axes label
+ *navigate* [ *True* | *False* ]
+ *navigate_mode* [ 'PAN' | 'ZOOM' | None ] the navigation
+ toolbar button status
+ *position* [left, bottom, width, height] in
+ class:`~matplotlib.figure.Figure` coords
+ *sharex* an class:`~matplotlib.axes.Axes` instance
+ to share the x-axis with
+ *sharey* an class:`~matplotlib.axes.Axes` instance
+ to share the y-axis with
+ *title* the title string
+ *visible* [ *True* | *False* ] whether the axes is
+ visible
+ *xlabel* the xlabel
+ *xlim* (*xmin*, *xmax*) view limits
+ *xscale* [%(scale)s]
+ *xticklabels* sequence of strings
+ *xticks* sequence of floats
+ *ylabel* the ylabel strings
+ *ylim* (*ymin*, *ymax*) view limits
+ *yscale* [%(scale)s]
+ *yticklabels* sequence of strings
+ *yticks* sequence of floats
+ ================ =========================================
""" % {'scale': ' | '.join([repr(x) for x in mscale.get_scale_names()])}
martist.Artist.__init__(self)
if isinstance(rect, mtransforms.Bbox):
@@ -562,7 +578,10 @@
self._ycid = self.yaxis.callbacks.connect('units finalize', self.relim)
def get_window_extent(self, *args, **kwargs):
- 'get the axes bounding box in display space; args and kwargs are empty'
+ '''
+ get the axes bounding box in display space; *args* and
+ *kwargs* are empty
+ '''
return self.bbox
def _init_axis(self):
@@ -573,9 +592,9 @@
def set_figure(self, fig):
"""
- Set the Axes' figure
+ Set the class:`~matplotlib.axes.Axes` figure
- accepts a Figure instance
+ accepts a class:`~matplotlib.figure.Figure` instance
"""
martist.Artist.set_figure(self, fig)
@@ -589,8 +608,9 @@
def _set_lim_and_transforms(self):
"""
- set the dataLim and viewLim BBox attributes and the
- transScale, transData, transLimits and transAxes
+ set the *dataLim* and *viewLim*
+ :class:`~matplotlib.transforms.Bbox` attributes and the
+ *transScale*, *transData*, *transLimits* and *transAxes*
transformations.
"""
self.transAxes = mtransforms.BboxTransformTo(self.bbox)
@@ -620,9 +640,11 @@
and gridlines. The x-direction is in data coordinates and the
y-direction is in axis coordinates.
- This transformation is primarily used by the Axis class, and
- is meant to be overridden by new kinds of projections that may
- need to place axis elements in different locations.
+ .. note::
+ This transformation is primarily used by the
+ :class:`~matplotlib.axis.Axis` class, and is meant to be
+ overridden by new kinds of projections that may need to
+ place axis elements in different locations.
"""
return self._xaxis_transform
@@ -631,16 +653,19 @@
Get the transformation used for drawing x-axis labels, which
will add the given amount of padding (in points) between the
axes and the label. The x-direction is in data coordinates
- and the y-direction is in axis coordinates. Returns a 3-tuple
- of the form::
+ and the y-direction is in axis coordinates. Returns a
+ 3-tuple of the form::
(transform, valign, halign)
- where valign and halign are requested alignments for the text.
+ where *valign* and *halign* are requested alignments for the
+ text.
- This transformation is primarily used by the Axis class, and
- is meant to be overridden by new kinds of projections that may
- need to place axis elements in different locations.
+ .. note::
+ This transformation is primarily used by the
+ :class:`~matplotlib.axis.Axis` class, and is meant to be
+ overridden by new kinds of projections that may need to
+ place axis elements in different locations.
"""
return (self._xaxis_transform +
mtransforms.ScaledTranslation(0, -1 * pad_points / 72.0,
@@ -657,11 +682,14 @@
(transform, valign, halign)
- where valign and halign are requested alignments for the text.
+ where *valign* and *halign* are requested alignments for the
+ text.
- This transformation is primarily used by the Axis class, and
- is meant to be overridden by new kinds of projections that may
- need to place axis elements in different locations.
+ .. note::
+ This transformation is primarily used by the
+ :class:`~matplotlib.axis.Axis` class, and is meant to be
+ overridden by new kinds of projections that may need to
+ place axis elements in different locations.
"""
return (self._xaxis_transform +
mtransforms.ScaledTranslation(0, pad_points / 72.0,
@@ -674,9 +702,11 @@
and gridlines. The x-direction is in axis coordinates and the
y-direction is in data coordinates.
- This transformation is primarily used by the Axis class, and
- is meant to be overridden by new kinds of projections that may
- need to place axis elements in different locations.
+ .. note::
+ This transformation is primarily used by the
+ :class:`~matplotlib.axis.Axis` class, and is meant to be
+ overridden by new kinds of projections that may need to
+ place axis elements in different locations.
"""
return self._yaxis_transform
@@ -690,11 +720,14 @@
(transform, valign, halign)
- where valign and halign are requested alignments for the text.
+ where *valign* and *halign* are requested alignments for the
+ text.
- This transformation is primarily used by the Axis class, and
- is meant to be overridden by new kinds of projections that may
- need to place axis elements in different locations.
+ .. note::
+ This transformation is primarily used by the
+ :class:`~matplotlib.axis.Axis` class, and is meant to be
+ overridden by new kinds of projections that may need to
+ place axis elements in different locations.
"""
return (self._yaxis_transform +
mtransforms.ScaledTranslation(-1 * pad_points / 72.0, 0,
@@ -711,11 +744,15 @@
(transform, valign, halign)
- where valign and halign are requested alignments for the text.
+ where *valign* and *halign* are requested alignments for the
+ text.
- This transformation is primarily used by the Axis class, and
- is meant to be overridden by new kinds of projections that may
- need to place axis elements in different locations.
+ .. note::
+
+ This transformation is primarily used by the
+ :class:`~matplotlib.axis.Axis` class, and is meant to be
+ overridden by new kinds of projections that may need to
+ place axis elements in different locations.
"""
return (self._yaxis_transform +
mtransforms.ScaledTranslation(pad_points / 72.0, 0,
@@ -740,19 +777,20 @@
def set_position(self, pos, which='both'):
"""
- Set the axes position with pos = [left, bottom, width, height]
- in relative 0,1 coords
+ Set the axes position with::
+ pos = [left, bottom, width, height]
+
+ in relative 0,1 coords, or *pos* can be a
+ :class:`~matplotlib.transforms.Bbox`
+
There are two position variables: one which is ultimately
- used, but which may be modified by apply_aspect, and a second
- which is the starting point for apply_aspect.
+ used, but which may be modified by :meth:`apply_aspect`, and a
+ second which is the starting point for :meth:`apply_aspect`.
- Required arguments:
- pos:
- len(4) sequence of floats, or a Bbox object
Optional keyword arguments:
- which:
+ *which*
========== ====================
value description
@@ -786,7 +824,8 @@
In the standard axes, this is a rectangle, but in other
projections it may not be.
- Intended to be overridden by new projection types.
+ .. note::
+ Intended to be overridden by new projection types.
"""
return mpatches.Rectangle((0.0, 0.0), 1.0, 1.0)
@@ -882,8 +921,8 @@
hold(b=None)
- Set the hold state. If hold is None (default), toggle the
- hold state. Else set the hold state to boolean value b.
+ Set the hold state. If *hold* is *None* (default), toggle the
+ *hold* state. Else set the *hold* state to boolean value *b*.
Examples:
@@ -910,7 +949,7 @@
def set_aspect(self, aspect, adjustable=None, anchor=None):
"""
- aspect:
+ *aspect*
======== ================================================
value description
@@ -923,7 +962,7 @@
aspect='equal'.
======== ================================================
- adjustable:
+ *adjustable*
========= ============================
value description
@@ -932,7 +971,7 @@
'datalim' change xlim or ylim
========= ============================
- anchor:
+ *anchor*
===== =====================
value description
@@ -974,7 +1013,7 @@
def set_anchor(self, anchor):
"""
- anchor:
+ *anchor*
===== ============
value description
@@ -1012,7 +1051,7 @@
def apply_aspect(self, position=None):
'''
- Use self._aspect and self._adjustable to modify the
+ Use :meth:`_aspect` and :meth:`_adjustable` to modify the
axes box or the view limits.
'''
if position is None:
@@ -1109,8 +1148,8 @@
Convenience method for manipulating the x and y view limits
and the aspect ratio of the plot.
- kwargs are passed on to set_xlim and set_ylim -- see their
- docstrings for details
+ *kwargs* are passed on to :meth:`set_xlim` and
+ :meth:`set_ylim`
'''
if len(v)==1 and is_string_like(v[0]):
s = v[0].lower()
@@ -1164,7 +1203,9 @@
def get_child_artists(self):
"""
- Return a list of artists the axes contains. Deprecated
+ Return a list of artists the axes contains.
+
+ .. deprecated:: 0.98
"""
raise DeprecationWarning('Use get_children instead')
@@ -1213,9 +1254,9 @@
#### Adding and tracking artists
def has_data(self):
- '''Return true if any artists have been added to axes.
+ '''Return *True* if any artists have been added to axes.
- This should not be used to determine whether the dataLim
+ This should not be used to determine whether the *dataLim*
need to be updated, and may not actually be useful for
anything.
'''
@@ -1226,7 +1267,7 @@
len(self.patches))>0
def add_artist(self, a):
- 'Add any artist to the axes'
+ 'Add any :class:`~matplotlib.artist.Artist` to the axes'
a.set_axes(self)
self.artists.append(a)
self._set_artist_props(a)
@@ -1234,7 +1275,10 @@
a._remove_method = lambda h: self.artists.remove(h)
def add_collection(self, collection, autolim=True):
- 'add a Collection instance to Axes'
+ '''
+ add a :class:`~matplotlib.collections.Collection` instance
+ to the axes
+ '''
label = collection.get_label()
if not label:
collection.set_label('collection%d'%len(self.collections))
@@ -1247,7 +1291,10 @@
collection._remove_method = lambda h: self.collections.remove(h)
def add_line(self, line):
- 'Add a line to the list of plot lines'
+ '''
+ Add a :class:`~matplotlib.lines.Line2D` to the list of plot
+ lines
+ '''
self._set_artist_props(line)
line.set_clip_path(self.axesPatch)
@@ -1263,9 +1310,10 @@
def add_patch(self, p):
"""
- Add a patch to the list of Axes patches; the clipbox will be
- set to the Axes clipping box. If the transform is not set, it
- wil be set to self.transData.
+ Add a :class:`~matplotlib.patches.Patch` *p* to the list of
+ axes patches; the clipbox will be set to the Axes clipping
+ box. If the transform is not set, it will be set to
+ :attr:`transData`.
"""
self._set_artist_props(p)
@@ -1275,7 +1323,7 @@
p._remove_method = lambda h: self.patches.remove(h)
def _update_patch_limits(self, p):
- 'update the datalimits for patch p'
+ 'update the data limits for patch *p*'
# hist can add zero height Rectangles, which is useful to keep
# the bins, counts and patches lined up, but it throws off log
# scaling. We'll ignore rects with zero height or width in
@@ -1291,14 +1339,17 @@
self.update_datalim(vertices)
def add_table(self, tab):
- 'Add a table instance to the list of axes tables'
+ '''
+ Add a :class:`~matplotlib.tables.Table` instance to the
+ list of axes tables
+ '''
self._set_artist_props(tab)
self.tables.append(tab)
tab.set_clip_path(self.axesPatch)
tab._remove_method = lambda h: self.tables.remove(h)
def relim(self):
- 'recompute the datalimits based on current artists'
+ 'recompute the data limits based on current artists'
self.dataLim.ignore(True)
self.ignore_existing_data_limits = True
for line in self.lines:
@@ -1331,11 +1382,14 @@
self.ignore_existing_data_limits = False
def update_datalim_bounds(self, bounds):
- 'Update the datalim to include the given Bbox'
+ '''
+ Update the datalim to include the given
+ :class:`~matplotlib.transforms.Bbox` *bounds*
+ '''
self.dataLim.set(Bbox.union([self.dataLim, bounds]))
def _process_unit_info(self, xdata=None, ydata=None, kwargs=None):
- 'look for unit kwargs and update the axis instances as necessary'
+ 'look for unit *kwargs* and update the axis instances as necessary'
if self.xaxis is None or self.yaxis is None: return
@@ -1361,7 +1415,10 @@
self.yaxis.set_units(yunits)
def in_axes(self, mouseevent):
- 'return True if the given mouseevent (in display coords) is in the Axes'
+ '''
+ return *True* if the given *mouseevent* (in display coords)
+ is in the Axes
+ '''
return self.axesPatch.contains(mouseevent)[0]
def get_autoscale_on(self):
@@ -1374,7 +1431,7 @@
"""
Set whether autoscaling is applied on plot commands
- accepts: True|False
+ accepts: [ *True* | *False* ]
"""
self._autoscaleon = b
@@ -1382,7 +1439,7 @@
"""
autoscale the view limits using the data limits. You can
selectively autoscale only a single axis, eg, the xaxis by
- setting scaley to False. The autoscaling preserves any
+ setting *scaley* to *False*. The autoscaling preserves any
axis direction reversal that has already been done.
"""
# if image data only just use the datalim
@@ -1528,13 +1585,13 @@
"""
Set whether the axes rectangle patch is drawn
- ACCEPTS: [ True | False ]
+ ACCEPTS: [ *True* | *False* ]
"""
self._frameon = b
def get_axisbelow(self):
"""
- Get whether axist below is true or not
+ Get whether axis below is true or not
"""
return self._axisbelow
@@ -1542,7 +1599,7 @@
"""
Set whether the axis ticks and gridlines are above or below most artists
- ACCEPTS: [ True | False ]
+ ACCEPTS: [ *True* | *False* ]
"""
self._axisbelow = b
@@ -1554,11 +1611,11 @@
Set the axes grids on or off; *b* is a boolean
- If *b* is *None* and len(kwargs)==0, toggle the grid state. If
- kwargs are supplied, it is assumed that you want a grid and *b*
+ If *b* is *None* and ``len(kwargs)==0``, toggle the grid state. If
+ *kwargs* are supplied, it is assumed that you want a grid and *b*
is thus set to *True*
- kawrgs are used to set the grid line properties, eg::
+ *kawrgs* are used to set the grid line properties, eg::
ax.grid(color='r', linestyle='-', linewidth=2)
@@ -1581,17 +1638,20 @@
======= =====================================
Keyword Description
======= =====================================
- style [ 'sci' (or 'scientific') | 'plain' ]
+ *style* [ 'sci' (or 'scientific') | 'plain' ]
plain turns off scientific notation
- axis [ 'x' | 'y' | 'both' ]
+ *axis* [ 'x' | 'y' | 'both' ]
======= =====================================
Only the major ticks are affected.
- If the method is called when the ScalarFormatter is not
- the one being used, an AttributeError will be raised with
- no additional error message.
+ If the method is called when the
+ :class:`~matplotlib.ticker.ScalarFormatter` is not the
+ :class:`~matplotlib.ticker.Formatter` being used, an
+ :exc:`AttributeError` will be raised with no additional error
+ message.
- Additional capabilities and/or friendlier error checking may be added.
+ Additional capabilities and/or friendlier error checking may
+ be added.
"""
style = kwargs.pop('style', '').lower()
@@ -1631,7 +1691,8 @@
"""
set the axes background color
- ACCEPTS: any matplotlib color - see help(colors)
+ ACCEPTS: any matplotlib color - see
+ :func:`~matplotlib.pyplot.colors`
"""
self._axisbg = color
@@ -1688,7 +1749,7 @@
def get_xlim(self):
"""
- Get the x-axis range [xmin, xmax]
+ Get the x-axis range [*xmin*, *xmax*]
"""
return self.viewLim.intervalx
@@ -1700,7 +1761,7 @@
Set the limits for the xaxis
- Returns the current xlimits as a length 2 tuple: [xmin, xmax]
+ Returns the current xlimits as a length 2 tuple: [*xmin*, *xmax*]
Examples::
@@ -1709,15 +1770,14 @@
set_xlim(xmin=1) # xmax unchanged
set_xlim(xmax=1) # xmin unchanged
- Valid keyword arguments:
+ Keyword arguments:
- ======= ==============================
- Keyword Description
- ======= ==============================
- xmin the min of the xlim
- xmax the max of the xlim
- emit notify observers of lim change
- ======= ==============================
+ *ymin*: scalar
+ the min of the ylim
+ *ymax*: scalar
+ the max of the ylim
+ *emit*: [ True | False ]
+ notify observers of lim change
ACCEPTS: len(2) sequence of floats
"""
@@ -1783,7 +1843,7 @@
def set_xticks(self, ticks, minor=False):
"""
- Set the x ticks with list of ticks
+ Set the x ticks with list of *ticks*
ACCEPTS: sequence of floats
"""
@@ -1807,10 +1867,11 @@
set_xticklabels(labels, fontdict=None, minor=False, **kwargs)
- Set the xtick labels with list of strings labels Return a list of axis
- text instances.
+ Set the xtick labels with list of strings *labels*. Return a
+ list of axis text instances.
- kwargs set the Text properties. Valid properties are
+ *kwargs* set the :class:`~matplotlib.text.Text` properties.
+ Valid properties are
%(Text)s
ACCEPTS: sequence of strings
@@ -1861,7 +1922,7 @@
def get_ylim(self):
"""
- Get the y-axis range [xmin, xmax]
+ Get the y-axis range [*ymin*, *ymax*]
"""
return self.viewLim.intervaly
@@ -1880,11 +1941,11 @@
Keyword arguments:
- ymin: scalar
+ *ymin*: scalar
the min of the ylim
- ymax: scalar
+ *ymax*: scalar
the max of the ylim
- emit: [ True | False ]
+ *emit*: [ True | False ]
notify observers of lim change
Returns the current ylimits as a length 2 tuple
@@ -1950,13 +2011,13 @@
def set_yticks(self, ticks, minor=False):
"""
- Set the y ticks with list of ticks
+ Set the y ticks with list of *ticks*
ACCEPTS: sequence of floats
Keyword arguments:
- minor: [ False | True ]
+ *minor*: [ False | True ]
Sets the minor ticks if True
"""
return self.yaxis.set_ticks(ticks, minor=minor)
@@ -1979,10 +2040,11 @@
set_yticklabels(labels, fontdict=None, minor=False, **kwargs)
- Set the ytick labels with list of strings labels. Return a list of
- Text instances.
+ Set the ytick labels with list of strings *labels*. Return a list of
+ :class:`~matplotlib.text.Text` instances.
- kwargs set Text properties for the labels. Valid properties are
+ *kwargs* set :class:`~matplotlib.text.Text` properties for the labels.
+ Valid properties are
%(Text)s
ACCEPTS: sequence of strings
@@ -1993,7 +2055,7 @@
def xaxis_date(self, tz=None):
"""Sets up x-axis ticks and labels that treat the x data as dates.
- tz is the time zone to use in labeling dates. Defaults to rc value.
+ *tz* is the time zone to use in labeling dates. Defaults to rc value.
"""
if self.ignore_existing_data_limits:
@@ -2022,7 +2084,7 @@
def yaxis_date(self, tz=None):
"""Sets up y-axis ticks a...
[truncated message content] |
|
From: <ds...@us...> - 2008-06-23 18:15:44
|
Revision: 5651
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5651&view=rev
Author: dsdale
Date: 2008-06-23 11:15:01 -0700 (Mon, 23 Jun 2008)
Log Message:
-----------
updated axis docstrings
converted colors docstrings, added to api reference
Modified Paths:
--------------
trunk/matplotlib/doc/api/index.rst
trunk/matplotlib/doc/devel/outline.rst
trunk/matplotlib/lib/matplotlib/axis.py
trunk/matplotlib/lib/matplotlib/colors.py
Added Paths:
-----------
trunk/matplotlib/doc/api/colors_api.rst
Added: trunk/matplotlib/doc/api/colors_api.rst
===================================================================
--- trunk/matplotlib/doc/api/colors_api.rst (rev 0)
+++ trunk/matplotlib/doc/api/colors_api.rst 2008-06-23 18:15:01 UTC (rev 5651)
@@ -0,0 +1,12 @@
+*****************
+matplotlib colors
+*****************
+
+
+:mod:`matplotlib.colors`
+========================
+
+.. automodule:: matplotlib.colors
+ :members:
+ :undoc-members:
+ :show-inheritance:
Modified: trunk/matplotlib/doc/api/index.rst
===================================================================
--- trunk/matplotlib/doc/api/index.rst 2008-06-23 17:46:26 UTC (rev 5650)
+++ trunk/matplotlib/doc/api/index.rst 2008-06-23 18:15:01 UTC (rev 5651)
@@ -21,5 +21,6 @@
cm_api.rst
collections_api.rst
colorbar_api.rst
+ colors_api.rst
pyplot_api.rst
index_backend_api.rst
Modified: trunk/matplotlib/doc/devel/outline.rst
===================================================================
--- trunk/matplotlib/doc/devel/outline.rst 2008-06-23 17:46:26 UTC (rev 5650)
+++ trunk/matplotlib/doc/devel/outline.rst 2008-06-23 18:15:01 UTC (rev 5651)
@@ -114,13 +114,13 @@
afm converted
artist converted
axes converted
-axis needs conversion
-backend_bases needs conversion
-cbook needs conversion
-cm needs conversion
-collections needs conversion
-colorbar needs conversion
-colors Darren needs conversion
+axis converted
+backend_bases converted
+cbook converted
+cm converted
+collections converted
+colorbar converted
+colors converted
contour needs conversion
dates Darren needs conversion
dviread Darren needs conversion
@@ -137,7 +137,7 @@
patches needs conversion
path needs conversion
pylab needs conversion
-pyplot needs conversion
+pyplot converted
quiver needs conversion
rcsetup needs conversion
scale needs conversion
Modified: trunk/matplotlib/lib/matplotlib/axis.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/axis.py 2008-06-23 17:46:26 UTC (rev 5650)
+++ trunk/matplotlib/lib/matplotlib/axis.py 2008-06-23 18:15:01 UTC (rev 5651)
@@ -315,7 +315,7 @@
return l
def update_position(self, loc):
- 'Set the location of tick in data coords with scalar loc'
+ 'Set the location of tick in data coords with scalar *loc*'
x = loc
nonlinear = (hasattr(self.axes, 'yaxis') and
@@ -504,8 +504,8 @@
"""
Public attributes
- * transData - transform data coords to display coords
- * transAxis - transform axis coords to display coords
+ * :attr:`transData` - transform data coords to display coords
+ * :attr:`transAxis` - transform axis coords to display coords
"""
LABELPAD = 5
@@ -909,14 +909,14 @@
def grid(self, b=None, which='major', **kwargs):
"""
- Set the axis grid on or off; b is a boolean use which =
+ Set the axis grid on or off; b is a boolean use *which* =
'major' | 'minor' to set the grid for major or minor ticks
- if b is None and len(kwargs)==0, toggle the grid state. If
- kwargs are supplied, it is assumed you want the grid on and b
+ if *b* is *None* and len(kwargs)==0, toggle the grid state. If
+ *kwargs* are supplied, it is assumed you want the grid on and *b*
will be set to True
- kwargs are used to set the line properties of the grids, eg,
+ *kwargs* are used to set the line properties of the grids, eg,
xax.grid(color='r', linestyle='-', linewidth=2)
"""
@@ -939,8 +939,8 @@
def update_units(self, data):
"""
- introspect data for units converter and update the
- axis.converter instance if necessary. Return true is data is
+ introspect *data* for units converter and update the
+ axis.converter instance if necessary. Return *True* is *data* is
registered for unit conversion
"""
@@ -1022,7 +1022,7 @@
"""
Set the formatter of the major ticker
- ACCEPTS: A Formatter instance
+ ACCEPTS: A :class:`~matplotlib.ticker.Formatter` instance
"""
self.major.formatter = formatter
formatter.set_axis(self)
@@ -1032,7 +1032,7 @@
"""
Set the formatter of the minor ticker
- ACCEPTS: A Formatter instance
+ ACCEPTS: A :class:`~matplotlib.ticker.Formatter` instance
"""
self.minor.formatter = formatter
formatter.set_axis(self)
@@ -1042,7 +1042,7 @@
"""
Set the locator of the major ticker
- ACCEPTS: a Locator instance
+ ACCEPTS: a :class:`~matplotlib.ticker.Locator` instance
"""
self.major.locator = locator
locator.set_axis(self)
@@ -1052,7 +1052,7 @@
"""
Set the locator of the minor ticker
- ACCEPTS: a Locator instance
+ ACCEPTS: a :class:`~matplotlib.ticker.Locator` instance
"""
self.minor.locator = locator
locator.set_axis(self)
@@ -1069,7 +1069,7 @@
def set_ticklabels(self, ticklabels, *args, **kwargs):
"""
Set the text values of the tick labels. Return a list of Text
- instances. Use kwarg minor=True to select minor ticks.
+ instances. Use *kwarg* *minor=True* to select minor ticks.
ACCEPTS: sequence of strings
"""
@@ -1128,11 +1128,11 @@
raise NotImplementedError('Derived must override')
def pan(self, numsteps):
- 'Pan numticks (can be positive or negative)'
+ 'Pan *numsteps* (can be positive or negative)'
self.major.locator.pan(numsteps)
def zoom(self, direction):
- "Zoom in/out on axis; if direction is >0 zoom in, else zoom out"
+ "Zoom in/out on axis; if *direction* is >0 zoom in, else zoom out"
self.major.locator.zoom(direction)
class XAxis(Axis):
@@ -1372,7 +1372,7 @@
def contains(self,mouseevent):
"""Test whether the mouse event occurred in the y axis.
- Returns T/F, {}
+ Returns *True* | *False*
"""
if callable(self._contains): return self._contains(self,mouseevent)
Modified: trunk/matplotlib/lib/matplotlib/colors.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/colors.py 2008-06-23 17:46:26 UTC (rev 5650)
+++ trunk/matplotlib/lib/matplotlib/colors.py 2008-06-23 18:15:01 UTC (rev 5651)
@@ -18,17 +18,17 @@
w : white
Gray shades can be given as a string encoding a float in the 0-1
-range, e.g.,
+range, e.g.::
color = '0.75'
For a greater range of colors, you have two options. You can specify
-the color using an html hex string, as in
+the color using an html hex string, as in::
color = '#eeefff'
-or you can pass an R,G,B tuple, where each of R,G,B are in the range
-[0,1].
+or you can pass an *R* , *G* , *B* tuple, where each of *R* , *G* , *B*
+are in the range [0,1].
Finally, legal html names for colors, like 'red', 'burlywood' and
'chartreuse' are supported.
@@ -203,7 +203,7 @@
def hex2color(s):
"""
- Take a hex string 's' and return the corresponding rgb 3-tuple
+ Take a hex string *s* and return the corresponding rgb 3-tuple
Example: #efefef -> (0.93725, 0.93725, 0.93725)
"""
if not isinstance(s, basestring):
@@ -227,15 +227,17 @@
cache = {}
def to_rgb(self, arg):
"""
- Returns an RGB tuple of three floats from 0-1.
+ Returns an *RGB* tuple of three floats from 0-1.
- arg can be an RGB or RGBA sequence or a string in any of several forms:
+ *arg* can be an *RGB* or *RGBA* sequence or a string in any of
+ several forms:
+
1) a letter from the set 'rgbcmykw'
2) a hex color string, like '#00FFFF'
3) a standard name, like 'aqua'
4) a float, like '0.4', indicating gray on a 0-1 scale
- if arg is RGBA, the A will simply be discarded.
+ if *arg* is *RGBA*, the *A* will simply be discarded.
"""
try: return self.cache[arg]
except KeyError: pass
@@ -283,11 +285,11 @@
def to_rgba(self, arg, alpha=None):
"""
- Returns an RGBA tuple of four floats from 0-1.
+ Returns an *RGBA* tuple of four floats from 0-1.
- For acceptable values of arg, see to_rgb.
- If arg is an RGBA sequence and alpha is not None,
- alpha will replace the original A.
+ For acceptable values of *arg*, see :meth:`to_rgb`.
+ If *arg* is an *RGBA* sequence and *alpha* is not *None*,
+ *alpha* will replace the original *A*.
"""
try:
if not cbook.is_string_like(arg) and cbook.iterable(arg):
@@ -313,13 +315,13 @@
def to_rgba_array(self, c, alpha=None):
"""
- Returns an Numpy array of rgba tuples.
+ Returns an Numpy array of *RGBA* tuples.
Accepts a single mpl color spec or a sequence of specs.
If the sequence is a list or array, the items are changed in place,
but an array copy is still returned.
- Special case to handle "no color": if c is "none" (case-insensitive),
+ Special case to handle "no color": if *c* is "none" (case-insensitive),
then an empty array will be returned. Same for an empty list.
"""
try:
@@ -345,9 +347,9 @@
colorConverter = ColorConverter()
def makeMappingArray(N, data):
- """Create an N-element 1-d lookup table
+ """Create an *N* -element 1-d lookup table
- data represented by a list of x,y0,y1 mapping correspondences.
+ *data* represented by a list of x,y0,y1 mapping correspondences.
Each element in this list represents how a value between 0 and 1
(inclusive) represented by x is mapped to a corresponding value
between 0 and 1 (inclusive). The two values of y are to allow
@@ -358,7 +360,7 @@
all values of x must be in increasing order. Values between
the given mapping points are determined by simple linear interpolation.
- The function returns an array "result" where result[x*(N-1)]
+ The function returns an array "result" where ``result[x*(N-1)]``
gives the closest value for values of x between 0 and 1.
"""
try:
@@ -400,14 +402,16 @@
"""Base class for all scalar to rgb mappings
Important methods:
- set_bad()
- set_under()
- set_over()
+
+ * :meth:`set_bad`
+ * :meth:`set_under`
+ * :meth:`set_over`
"""
def __init__(self, name, N=256):
- """Public class attributes:
- self.N: number of rgb quantization levels
- self.name: name of colormap
+ """
+ Public class attributes:
+ :attr:`N` : number of rgb quantization levels
+ :attr:`name` : name of colormap
"""
self.name = name
@@ -423,7 +427,7 @@
def __call__(self, X, alpha=1.0, bytes=False):
"""
- X is either a scalar or an array (of any dimension).
+ *X* is either a scalar or an array (of any dimension).
If scalar, a tuple of rgba values is returned, otherwise
an array with the new shape = oldshape+(4,). If the X-values
are integers, then they are used as indices into the array.
@@ -551,13 +555,22 @@
"""
Make a colormap from a list of colors.
- colors is a list of matplotlib color specifications,
- or an equivalent Nx3 floating point array (N rgb values)
- name is a string to identify the colormap
- N is the number of entries in the map. The default is None,
+ *colors*
+ a list of matplotlib color specifications,
+ or an equivalent Nx3 floating point array (*N* rgb values)
+ *name*
+ a string to identify the colormap
+ *N*
+ the number of entries in the map. The default is *None*,
in which case there is one colormap entry for each
- element in the list of colors. If N < len(colors)
- the list will be truncated at N. If N > len(colors),
+ element in the list of colors. If::
+
+ N < len(colors)
+
+ the list will be truncated at *N*. If::
+
+ N > len(colors)
+
the list will be extended by repetition.
"""
self.colors = colors
@@ -600,16 +613,19 @@
"""
def __init__(self, vmin=None, vmax=None, clip=False):
"""
- If vmin or vmax is not given, they are taken from the input's
- minimum and maximum value respectively. If clip is True and
+ If *vmin* or *vmax* is not given, they are taken from the input's
+ minimum and maximum value respectively. If *clip* is *True* and
the given value falls outside the range, the returned value
- will be 0 or 1, whichever is closer. Returns 0 if vmin==vmax.
+ will be 0 or 1, whichever is closer. Returns 0 if::
+
+ vmin==vmax
+
Works with scalars or arrays, including masked arrays. If
- clip is True, masked values are set to 1; otherwise they
+ *clip* is *True*, masked values are set to 1; otherwise they
remain masked. Clipping silently defeats the purpose of setting
the over, under, and masked colors in the colormap, so it is
likely to lead to surprises; therefore the default is
- clip=False.
+ *clip* = *False*.
"""
self.vmin = vmin
self.vmax = vmax
@@ -656,7 +672,7 @@
def autoscale(self, A):
'''
- Set vmin, vmax to min, max of A.
+ Set *vmin*, *vmax* to min, max of *A*.
'''
self.vmin = ma.minimum(A)
self.vmax = ma.maximum(A)
@@ -718,8 +734,9 @@
'''
Generate a colormap index based on discrete intervals.
- Unlike Normalize or LogNorm, BoundaryNorm maps values
- to integers instead of to the interval 0-1.
+ Unlike :class:`Normalize` or :class:`LogNorm`,
+ :class:`BoundaryNorm` maps values to integers instead of to the
+ interval 0-1.
Mapping to the 0-1 interval could have been done via
piece-wise linear interpolation, but using integers seems
@@ -728,17 +745,22 @@
'''
def __init__(self, boundaries, ncolors, clip=False):
'''
- args:
- boundaries: a monotonically increasing sequence
- ncolors: number of colors in the colormap to be used
+ *boundaries*
+ a monotonically increasing sequence
+ *ncolors*
+ number of colors in the colormap to be used
- If b[i] <= v < b[i+1] then v is mapped to color j;
+ If::
+
+ b[i] <= v < b[i+1]
+
+ then v is mapped to color j;
as i varies from 0 to len(boundaries)-2,
j goes from 0 to ncolors-1.
Out-of-range values are mapped to -1 if low and ncolors
if high; these are converted to valid indices by
- Colormap.__call__.
+ :meth:`Colormap.__call__` .
'''
self.clip = clip
self.vmin = boundaries[0]
@@ -778,7 +800,8 @@
class NoNorm(Normalize):
'''
Dummy replacement for Normalize, for the case where we
- want to use indices directly in a ScalarMappable.
+ want to use indices directly in a
+ :class:`~matplotlib.cm.ScalarMappable` .
'''
def __call__(self, value, clip=None):
return value
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2008-06-23 21:39:23
|
Revision: 5652
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5652&view=rev
Author: jdh2358
Date: 2008-06-23 14:39:11 -0700 (Mon, 23 Jun 2008)
Log Message:
-----------
draft idle/timeout api
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/afm.py
trunk/matplotlib/lib/matplotlib/backend_bases.py
trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py
Added Paths:
-----------
trunk/matplotlib/examples/event_handling/idle_and_timeout.py
Added: trunk/matplotlib/examples/event_handling/idle_and_timeout.py
===================================================================
--- trunk/matplotlib/examples/event_handling/idle_and_timeout.py (rev 0)
+++ trunk/matplotlib/examples/event_handling/idle_and_timeout.py 2008-06-23 21:39:11 UTC (rev 5652)
@@ -0,0 +1,32 @@
+"""
+Demonstrate/test the idle and timeout API
+"""
+import matplotlib.pyplot as plt
+
+fig = plt.figure()
+ax = fig.add_subplot(111)
+
+ax.plot(range(10))
+
+def on_idle(canvas):
+ on_idle.count +=1
+ print 'idle', on_idle.count
+ if on_idle.count==10:
+ canvas.mpl_source_remove(on_idle)
+ return True
+on_idle.count = 0
+
+def on_timeout(canvas):
+ on_timeout.count +=1
+ print 'timeout', on_timeout.count
+ if on_timeout.count==10:
+ canvas.mpl_source_remove(on_timeout)
+ return True
+on_timeout.count = 0
+
+fig.canvas.mpl_idle_add(on_idle)
+fig.canvas.mpl_timeout_add(100, on_timeout)
+
+plt.show()
+
+
Modified: trunk/matplotlib/lib/matplotlib/afm.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/afm.py 2008-06-23 18:15:01 UTC (rev 5651)
+++ trunk/matplotlib/lib/matplotlib/afm.py 2008-06-23 21:39:11 UTC (rev 5652)
@@ -11,7 +11,7 @@
3) Did more than I needed and it was easier to write my own than
figure out how to just get what I needed from theirs
-It is pretty easy to use, and requires only built-in python libs:
+It is pretty easy to use, and requires only built-in python libs::
>>> from afm import AFM
>>> fh = file('ptmr8a.afm')
Modified: trunk/matplotlib/lib/matplotlib/backend_bases.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backend_bases.py 2008-06-23 18:15:01 UTC (rev 5651)
+++ trunk/matplotlib/lib/matplotlib/backend_bases.py 2008-06-23 21:39:11 UTC (rev 5652)
@@ -1316,6 +1316,33 @@
newCanvas = FigureCanvasClass(self.figure)
return newCanvas
+ def mpl_idle_add(self, func, *args, **kwargs):
+ """
+ add func to idle handler. The signature of func is::
+
+ func(canvas, *args, **kwargs)
+
+ use :meth:`mpl_source_remove` to remove func from the idle handler.
+ """
+ raise NotImplementedError('GUI backend must override')
+
+ def mpl_timeout_add(self, millisec, func, *args, **kwargs):
+ """
+ add func to timeout handler; func will be called every
+ millisec. The signature of func is::
+
+ func(canvas, *args, **kwargs)
+
+ use :meth:`mpl_source_remove` to remove func from the timeout handler.
+ """
+ raise NotImplementedError('GUI backend must override')
+
+ def mpl_source_remove(self, func):
+ """
+ remove func from idle or timeout handler
+ """
+ raise NotImplementedError('GUI backend must override')
+
def mpl_connect(self, s, func):
"""
Connect event with string *s* to *func*. The signature of *func* is::
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py 2008-06-23 18:15:01 UTC (rev 5651)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py 2008-06-23 21:39:11 UTC (rev 5652)
@@ -172,6 +172,8 @@
self.set_flags(gtk.CAN_FOCUS)
self._renderer_init()
+ # maps idle/timeout func -> id, remove_func for later removal
+ self.sourced = dict()
def scroll_event(self, widget, event):
if _debug: print 'FigureCanvasGTK.%s' % fn_name()
@@ -394,6 +396,53 @@
gtk.gdk.flush()
gtk.gdk.threads_leave()
+
+ def mpl_idle_add(self, func, *args, **kwargs):
+ """
+ add func to idle handler. The signature of func is::
+
+ func(canvas, *args, **kwargs)
+
+ use :meth:`mpl_source_remove` to remove func from the idle handler.
+ """
+ idle_add = getattr(gobject, 'idle_add', getattr(gtk, 'idle_add'))
+ remove = getattr(gobject, 'source_remove', getattr(gtk, 'idle_remove'))
+
+ def wrap():
+ b = func(self, *args, **kwargs)
+ return True
+
+ id = idle_add(wrap)
+ self.sourced[func] = id, remove
+
+
+ def mpl_timeout_add(self, millisec, func, *args, **kwargs):
+ """
+ add func to timeout handler; func will be called every
+ millisec. The signature of func is::
+
+ func(canvas, *args, **kwargs)
+
+ use :meth:`mpl_source_remove` to remove func from the timeout handler.
+ """
+ timeout_add = getattr(gobject, 'timeout_add', getattr(gtk, 'timeout_add'))
+ remove = getattr(gobject, 'source_remove', getattr(gtk, 'timeout_remove'))
+ def wrap():
+ b = func(self, *args, **kwargs)
+ return True
+
+ id = timeout_add(millisec, wrap)
+ self.sourced[func] = id, remove
+
+
+ def mpl_source_remove(self, func):
+ """
+ remove func from idle or timeout handler
+ """
+ id, remove = self.sourced[func]
+ remove(id)
+ del self.sourced[func]
+
class FigureManagerGTK(FigureManagerBase):
"""
Public attributes
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2008-06-24 04:17:24
|
Revision: 5653
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5653&view=rev
Author: jdh2358
Date: 2008-06-23 21:17:21 -0700 (Mon, 23 Jun 2008)
Log Message:
-----------
replaced idle handler with idle event
Modified Paths:
--------------
trunk/matplotlib/examples/event_handling/idle_and_timeout.py
trunk/matplotlib/lib/matplotlib/backend_bases.py
trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py
trunk/matplotlib/lib/matplotlib/backends/backend_tkagg.py
trunk/matplotlib/lib/matplotlib/backends/backend_wx.py
trunk/matplotlib/lib/matplotlib/cbook.py
Modified: trunk/matplotlib/examples/event_handling/idle_and_timeout.py
===================================================================
--- trunk/matplotlib/examples/event_handling/idle_and_timeout.py 2008-06-23 21:39:11 UTC (rev 5652)
+++ trunk/matplotlib/examples/event_handling/idle_and_timeout.py 2008-06-24 04:17:21 UTC (rev 5653)
@@ -1,31 +1,43 @@
"""
Demonstrate/test the idle and timeout API
"""
+import numpy as np
import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot(111)
-ax.plot(range(10))
+t = np.arange(0.0, 2.0, 0.01)
+y1 = np.sin(2*np.pi*t)
+y2 = np.cos(2*np.pi*t)
+line1, = ax.plot(y1)
+line2, = ax.plot(y2)
-def on_idle(canvas):
+N = 100
+def on_idle(event):
on_idle.count +=1
print 'idle', on_idle.count
- if on_idle.count==10:
- canvas.mpl_source_remove(on_idle)
- return True
+ line1.set_ydata(np.sin(2*np.pi*t*(N-on_idle.count)/float(N)))
+ event.canvas.draw()
+ # test boolean return removal
+ if on_idle.count==N:
+ fig.canvas.mpl_disconnect(on_idle.cid)
+on_idle.cid = None
on_idle.count = 0
def on_timeout(canvas):
on_timeout.count +=1
+ line2.set_ydata(np.cos(2*np.pi*t*(N-on_idle.count)/float(N)))
+ line2.figure.canvas.draw()
print 'timeout', on_timeout.count
- if on_timeout.count==10:
- canvas.mpl_source_remove(on_timeout)
+ # test explicit removal
+ if on_timeout.count==N:
+ return False
return True
on_timeout.count = 0
-fig.canvas.mpl_idle_add(on_idle)
-fig.canvas.mpl_timeout_add(100, on_timeout)
+on_idle.cid = fig.canvas.mpl_connect('idle_event', on_idle)
+#fig.canvas.mpl_timeout_add(100, on_timeout)
plt.show()
Modified: trunk/matplotlib/lib/matplotlib/backend_bases.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backend_bases.py 2008-06-23 21:39:11 UTC (rev 5652)
+++ trunk/matplotlib/lib/matplotlib/backend_bases.py 2008-06-24 04:17:21 UTC (rev 5653)
@@ -651,6 +651,12 @@
self.canvas = canvas
self.guiEvent = guiEvent
+class IdleEvent(Event):
+ """
+ An event triggered by the GUI backend when it is idel -- useful
+ for passive animation
+ """
+ pass
class DrawEvent(Event):
"""
@@ -869,7 +875,7 @@
A :class:`matplotlib.figure.Figure` instance
"""
- events = (
+ events = [
'resize_event',
'draw_event',
'key_press_event',
@@ -879,7 +885,8 @@
'scroll_event',
'motion_notify_event',
'pick_event',
- )
+ 'idle_event',
+ ]
def __init__(self, figure):
@@ -1122,6 +1129,13 @@
guiEvent=guiEvent)
self.callbacks.process(s, event)
+ def idle_event(self, guiEvent=None):
+ 'call when GUI is idle'
+ s = 'idle_event'
+ event = IdleEvent(s, self, guiEvent=guiEvent)
+ self.callbacks.process(s, event)
+
+
def draw(self, *args, **kwargs):
"""
Render the :class:`~matplotlib.figure.Figure`
@@ -1320,8 +1334,11 @@
"""
add func to idle handler. The signature of func is::
- func(canvas, *args, **kwargs)
+ b = func(canvas, *args, **kwargs)
+ The function will continue to be called until func returns
+ False or a call to ``canvas.mpl_remove_source(func)``
+
use :meth:`mpl_source_remove` to remove func from the idle handler.
"""
raise NotImplementedError('GUI backend must override')
@@ -1331,7 +1348,8 @@
add func to timeout handler; func will be called every
millisec. The signature of func is::
- func(canvas, *args, **kwargs)
+ The function will continue to be called until func returns
+ False or a call to ``canvas.mpl_remove_source(func)``
use :meth:`mpl_source_remove` to remove func from the timeout handler.
"""
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py 2008-06-23 21:39:11 UTC (rev 5652)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py 2008-06-24 04:17:21 UTC (rev 5653)
@@ -172,8 +172,7 @@
self.set_flags(gtk.CAN_FOCUS)
self._renderer_init()
- # maps idle/timeout func -> id, remove_func for later removal
- self.sourced = dict()
+ gobject.idle_add(self.idle_event)
def scroll_event(self, widget, event):
if _debug: print 'FigureCanvasGTK.%s' % fn_name()
@@ -397,52 +396,6 @@
gtk.gdk.threads_leave()
- def mpl_idle_add(self, func, *args, **kwargs):
- """
- add func to idle handler. The signature of func is::
-
- func(canvas, *args, **kwargs)
-
- use :meth:`mpl_source_remove` to remove func from the idle handler.
- """
- idle_add = getattr(gobject, 'idle_add', getattr(gtk, 'idle_add'))
- remove = getattr(gobject, 'source_remove', getattr(gtk, 'idle_remove'))
-
- def wrap():
- b = func(self, *args, **kwargs)
- return True
-
- id = idle_add(wrap)
- self.sourced[func] = id, remove
-
-
- def mpl_timeout_add(self, millisec, func, *args, **kwargs):
- """
- add func to timeout handler; func will be called every
- millisec. The signature of func is::
-
- func(canvas, *args, **kwargs)
-
- use :meth:`mpl_source_remove` to remove func from the timeout handler.
- """
- timeout_add = getattr(gobject, 'timeout_add', getattr(gtk, 'timeout_add'))
- remove = getattr(gobject, 'source_remove', getattr(gtk, 'timeout_remove'))
- def wrap():
- b = func(self, *args, **kwargs)
- return True
-
- id = timeout_add(millisec, wrap)
- self.sourced[func] = id, remove
-
-
- def mpl_source_remove(self, func):
- """
- remove func from idle or timeout handler
- """
- id, remove = self.sourced[func]
- remove(id)
- del self.sourced[func]
-
class FigureManagerGTK(FigureManagerBase):
"""
Public attributes
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_tkagg.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_tkagg.py 2008-06-23 21:39:11 UTC (rev 5652)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_tkagg.py 2008-06-24 04:17:21 UTC (rev 5653)
@@ -21,6 +21,8 @@
import matplotlib.windowing as windowing
from matplotlib.widgets import SubplotTool
+import matplotlib.cbook as cbook
+
rcParams = matplotlib.rcParams
verbose = matplotlib.verbose
@@ -38,6 +40,7 @@
cursors.SELECT_REGION: "tcross",
}
+
def round(x):
return int(math.floor(x+0.5))
@@ -168,7 +171,17 @@
self._master = master
self._tkcanvas.focus_set()
+ # a dict from func-> cbook.Scheduler threads
+ self.sourced = dict()
+ # call the idle handler
+ def on_idle(*ignore):
+ self.idle_event()
+ return True
+ t = cbook.Idle(on_idle)
+
+ self._tkcanvas.after_idle(lambda *ignore: t.start())
+
def resize(self, event):
width, height = event.width, event.height
if self._resize_callback is not None:
@@ -221,6 +234,7 @@
y = self.figure.bbox.height - event.y
FigureCanvasBase.motion_notify_event(self, x, y, guiEvent=event)
+
def button_press_event(self, event):
x = event.x
# flipy so y=0 is bottom of canvas
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_wx.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_wx.py 2008-06-23 21:39:11 UTC (rev 5652)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_wx.py 2008-06-24 04:17:21 UTC (rev 5653)
@@ -713,6 +713,7 @@
self.Bind(wx.EVT_LEFT_UP, self._onLeftButtonUp)
self.Bind(wx.EVT_MOTION, self._onMotion)
self.Bind(wx.EVT_LEAVE_WINDOW, self._onLeave)
+ self.Bind(wx.EVT_IDLE, self._onIdle)
else:
# Event handlers 2.4
wx.EVT_SIZE(self, self._onSize)
@@ -728,6 +729,7 @@
wx.EVT_LEFT_UP(self, self._onLeftButtonUp)
wx.EVT_MOTION(self, self._onMotion)
wx.EVT_LEAVE_WINDOW(self, self._onLeave)
+ wx.EVT_IDLE(self, self._onIdle)
self.macros = {} # dict from wx id to seq of macros
@@ -1078,6 +1080,11 @@
return key
+ def _onIdle(self, evt):
+ 'a GUI idle event'
+ evt.Skip()
+ FigureCanvasBase.idle_event(self, guiEvent=evt)
+
def _onKeyDown(self, evt):
"""Capture key press."""
key = self._get_key(evt)
Modified: trunk/matplotlib/lib/matplotlib/cbook.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/cbook.py 2008-06-23 21:39:11 UTC (rev 5652)
+++ trunk/matplotlib/lib/matplotlib/cbook.py 2008-06-24 04:17:21 UTC (rev 5653)
@@ -3,7 +3,7 @@
from the Python Cookbook -- hence the name cbook
"""
from __future__ import generators
-import re, os, errno, sys, StringIO, traceback, locale
+import re, os, errno, sys, StringIO, traceback, locale, threading
import time, datetime
import numpy as np
@@ -152,7 +152,65 @@
func(*args, **kwargs)
+class Scheduler(threading.Thread):
+ """
+ Base class for timeout and idle scheduling
+ """
+ idlelock = threading.Lock()
+ id = 0
+ def __init__(self):
+ threading.Thread.__init__(self)
+ self.id = Scheduler.id
+ self._stopped = False
+ Scheduler.id += 1
+ self._stopevent = threading.Event()
+
+ def stop(self):
+ if self._stopped: return
+ self._stopevent.set()
+ self.join()
+ self._stopped = True
+
+class Timeout(Scheduler):
+ """
+ Schedule recurring events with a wait time in seconds
+ """
+ def __init__(self, wait, func):
+ Scheduler.__init__(self)
+ self.wait = wait
+ self.func = func
+
+ def run(self):
+
+ while not self._stopevent.isSet():
+ self._stopevent.wait(self.wait)
+ Scheduler.idlelock.acquire()
+ b = self.func(self)
+ Scheduler.idlelock.release()
+ if not b: break
+
+class Idle(Scheduler):
+ """
+ Schedule callbacks when scheduler is idle
+ """
+ # the prototype impl is a bit of a poor man's idle handler. It
+ # just implements a short wait time. But it will provide a
+ # placeholder for a proper impl ater
+ waittime = 0.05
+ def __init__(self, func):
+ Scheduler.__init__(self)
+ self.func = func
+
+ def run(self):
+
+ while not self._stopevent.isSet():
+ self._stopevent.wait(Idle.waittime)
+ Scheduler.idlelock.acquire()
+ b = self.func(self)
+ Scheduler.idlelock.release()
+ if not b: break
+
class silent_list(list):
"""
override repr when returning a list of matplotlib artists to
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2008-06-24 12:26:47
|
Revision: 5654
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5654&view=rev
Author: jdh2358
Date: 2008-06-24 05:26:43 -0700 (Tue, 24 Jun 2008)
Log Message:
-----------
added stefan's numpoints=1 marker patch
Modified Paths:
--------------
trunk/matplotlib/CHANGELOG
trunk/matplotlib/lib/matplotlib/legend.py
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2008-06-24 04:17:21 UTC (rev 5653)
+++ trunk/matplotlib/CHANGELOG 2008-06-24 12:26:43 UTC (rev 5654)
@@ -1,3 +1,6 @@
+2006-08-24 Applied Stefan's patch to draw a sinle centered marker over
+ a line with numpoints==1 - JDH
+
2008-06-23 Use splines to render circles in scatter plots - MGD
===============================================================
Modified: trunk/matplotlib/lib/matplotlib/legend.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/legend.py 2008-06-24 04:17:21 UTC (rev 5653)
+++ trunk/matplotlib/lib/matplotlib/legend.py 2008-06-24 12:26:43 UTC (rev 5654)
@@ -27,7 +27,7 @@
from matplotlib import rcParams
from artist import Artist
-from cbook import is_string_like, iterable, silent_list
+from cbook import is_string_like, iterable, silent_list, safezip
from font_manager import FontProperties
from lines import Line2D
from mlab import segments_intersect
@@ -118,7 +118,7 @@
proplist=[numpoints, pad, markerscale, labelsep, handlelen, handletextsep, axespad, shadow]
propnames=['numpoints', 'pad', 'markerscale', 'labelsep', 'handlelen', 'handletextsep', 'axespad', 'shadow']
- for name, value in zip(propnames,proplist):
+ for name, value in safezip(propnames,proplist):
if value is None:
value=rcParams["legend."+name]
setattr(self,name,value)
@@ -206,6 +206,8 @@
for h in self.legendHandles:
if h is not None:
h.draw(renderer)
+ if hasattr(h, '_legmarker'):
+ h._legmarker.draw(renderer)
if 0: bbox_artist(h, renderer)
for t in self.texts:
@@ -233,31 +235,46 @@
return ibox
def _get_handles(self, handles, texts):
+ handles = list(handles)
+ texts = list(texts)
HEIGHT = self._approx_text_height()
left = 0.5
ret = [] # the returned legend lines
- for handle, label in zip(handles, texts):
+ # we need to pad the text with empties for the numpoints=1
+ # centered marker proxy
+
+ for handle, label in safezip(handles, texts):
if self.numpoints > 1:
xdata = np.linspace(left, left + self.handlelen, self.numpoints)
+ xdata_marker = xdata
elif self.numpoints == 1:
xdata = np.linspace(left, left + self.handlelen, 2)
+ xdata_marker = [left + 0.5*self.handlelen]
x, y = label.get_position()
x -= self.handlelen + self.handletextsep
if isinstance(handle, Line2D):
- if self.numpoints == 1 and handle._marker != 'None':
- xdata = np.array([left + self.handlelen*0.5])
ydata = (y-HEIGHT/2)*np.ones(xdata.shape, float)
legline = Line2D(xdata, ydata)
+
legline.update_from(handle)
self._set_artist_props(legline) # after update
legline.set_clip_box(None)
legline.set_clip_path(None)
- legline.set_markersize(self.markerscale*legline.get_markersize())
+ ret.append(legline)
+ legline.set_marker('None')
- ret.append(legline)
+ legline_marker = Line2D(xdata_marker, ydata[:len(xdata_marker)])
+ legline_marker.update_from(handle)
+ legline_marker.set_linestyle('None')
+ self._set_artist_props(legline_marker)
+ # we don't want to add this to the return list because
+ # the texts and handles are assumed to be in one to ne
+ # correpondence.
+ legline._legmarker = legline_marker
+
elif isinstance(handle, Patch):
p = Rectangle(xy=(min(xdata), y-3/4*HEIGHT),
width = self.handlelen, height=HEIGHT/2,
@@ -477,7 +494,7 @@
return bboxa.bounds
hpos = []
- for t, tabove in zip(self.texts[1:], self.texts[:-1]):
+ for t, tabove in safezip(self.texts[1:], self.texts[:-1]):
x,y = t.get_position()
l,b,w,h = get_tbounds(tabove)
b -= self.labelsep
@@ -486,16 +503,18 @@
t.set_position( (x, b-0.1*h) )
# now do the same for last line
+
l,b,w,h = get_tbounds(self.texts[-1])
b -= self.labelsep
h += 2*self.labelsep
hpos.append( (b,h) )
- for handle, tup in zip(self.legendHandles, hpos):
+ for handle, tup in safezip(self.legendHandles, hpos):
y,h = tup
if isinstance(handle, Line2D):
ydata = y*np.ones(handle.get_xdata().shape, float)
- handle.set_ydata(ydata+h/2)
+ handle.set_ydata(ydata+h/2.)
+ handle._legmarker.set_ydata(ydata+h/2.)
elif isinstance(handle, Rectangle):
handle.set_y(y+1/4*h)
handle.set_height(h/2)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2008-06-24 18:13:48
|
Revision: 5667
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5667&view=rev
Author: jdh2358
Date: 2008-06-24 11:13:40 -0700 (Tue, 24 Jun 2008)
Log Message:
-----------
tagging 98.2
Modified Paths:
--------------
trunk/matplotlib/MANIFEST.in
trunk/matplotlib/doc/make.py
trunk/matplotlib/examples/user_interfaces/embedding_in_wx4.py
trunk/matplotlib/lib/matplotlib/__init__.py
trunk/matplotlib/lib/matplotlib/artist.py
trunk/matplotlib/lib/matplotlib/scale.py
Removed Paths:
-------------
trunk/matplotlib/examples/animation/dynamic_demo_wx.py
Modified: trunk/matplotlib/MANIFEST.in
===================================================================
--- trunk/matplotlib/MANIFEST.in 2008-06-24 18:06:22 UTC (rev 5666)
+++ trunk/matplotlib/MANIFEST.in 2008-06-24 18:13:40 UTC (rev 5667)
@@ -15,6 +15,7 @@
include lib/matplotlib/mpl-data/fonts/afm/*
recursive-include license LICENSE*
recursive-include examples *
+recursive-include doc *
recursive-include src *.cpp *.c *.h
recursive-include CXX *.cxx *.hxx *.c *.h
recursive-include agg24 *
Modified: trunk/matplotlib/doc/make.py
===================================================================
--- trunk/matplotlib/doc/make.py 2008-06-24 18:06:22 UTC (rev 5666)
+++ trunk/matplotlib/doc/make.py 2008-06-24 18:13:40 UTC (rev 5667)
@@ -20,9 +20,8 @@
def sfpdf():
'push a copy to the sf site'
+ os.system('cd build/latex; scp Matplotlib.pdf jd...@ma...:/home/groups/m/ma/matplotlib/htdocs/doc/')
- #os.system('cd build/latex; scp Matplotlib.pdf jd...@ma...:/home/groups/m/ma/matplotlib/htdocs/doc/')
-
def figs():
os.system('cd users/figures/ && python make.py')
Deleted: trunk/matplotlib/examples/animation/dynamic_demo_wx.py
===================================================================
--- trunk/matplotlib/examples/animation/dynamic_demo_wx.py 2008-06-24 18:06:22 UTC (rev 5666)
+++ trunk/matplotlib/examples/animation/dynamic_demo_wx.py 2008-06-24 18:13:40 UTC (rev 5667)
@@ -1,132 +0,0 @@
-#!/usr/bin/env python
-"""
-Copyright (C) Jeremy O'Donoghue, 2003
-
-License: This work is licensed under the PSF. A copy should be included
-with this source code, and is also available at
-http://www.python.org/psf/license.html
-
-This is a sample showing how to embed a matplotlib figure in a wxPanel,
-and update the contents whenever a timer event occurs. It is inspired
-by the GTK script dynamic_demo.py, by John Hunter (should be supplied with
-this file) but I have assumed that you may wish to embed a figure inside
-your own arbitrary frame, which makes the code slightly more complicated.
-
-It goes without saying that you can update the display on any event, not
-just a timer...
-
-Should you require a toolbar and navigation, inspire yourself from
-embedding_in_wx.py, which provides these features.
-
-Modification History:
-$Log$
-Revision 1.7 2005/06/15 20:24:56 jdh2358
-syncing for 82
-
-Revision 1.6 2004/10/26 18:08:13 astraw
-Converted to use new NavigationToolbar2 (from old Toolbar).
-
-Revision 1.5 2004/06/26 06:37:20 astraw
-Trivial bugfix to eliminate IndexError
-
-Revision 1.4 2004/05/03 12:12:26 jdh2358
-added bang header to examples
-
-Revision 1.3 2004/03/08 22:17:20 jdh2358
-
-* Fixed embedding_in_wx and dynamic_demo_wx examples
-
-* Ported build to darwin
-
-* Tk:
-
- removed default figman=None from nav toolbar since it needs the
- figman
-
- fixed close bug
-
- small changes to aid darwin build
-
-Revision 1.2 2004/02/26 20:22:58 jaytmiller
-Added the "numerix" Numeric/numarray selector module enabling matplotlib
-to work with either numarray or Numeric. See matplotlib.numerix.__doc__.
-
-Revision 1.1 2003/12/30 17:22:09 jodonoghue
-First version of dynamic_demo for backend_wx
-"""
-
-
-import matplotlib
-matplotlib.use('WX')
-from matplotlib.backends.backend_wx import FigureCanvasWx,\
- FigureManager, NavigationToolbar2Wx
-
-from matplotlib.figure import Figure
-import numpy
-from wx import *
-
-
-TIMER_ID = NewId()
-
-class PlotFigure(Frame):
-
- def __init__(self):
- Frame.__init__(self, None, -1, "Test embedded wxFigure")
-
- self.fig = Figure((5,4), 75)
- self.canvas = FigureCanvasWx(self, -1, self.fig)
- self.toolbar = NavigationToolbar2Wx(self.canvas)
- self.toolbar.Realize()
-
- # On Windows, default frame size behaviour is incorrect
- # you don't need this under Linux
- tw, th = self.toolbar.GetSizeTuple()
- fw, fh = self.canvas.GetSizeTuple()
- self.toolbar.SetSize(Size(fw, th))
-
- # Create a figure manager to manage things
- self.figmgr = FigureManager(self.canvas, 1, self)
- # Now put all into a sizer
- sizer = BoxSizer(VERTICAL)
- # This way of adding to sizer allows resizing
- sizer.Add(self.canvas, 1, LEFT|TOP|GROW)
- # Best to allow the toolbar to resize!
- sizer.Add(self.toolbar, 0, GROW)
- self.SetSizer(sizer)
- self.Fit()
- EVT_TIMER(self, TIMER_ID, self.onTimer)
-
- def init_plot_data(self):
- a = self.fig.add_subplot(111)
- self.ind = numpy.arange(60)
- tmp = []
- for i in range(60):
- tmp.append(numpy.sin((self.ind+i)*numpy.pi/15))
- self.X = numpy.array(tmp)
- self.lines = a.plot(self.X[:,0],'o')
- self.count = 0
-
- def GetToolBar(self):
- # You will need to override GetToolBar if you are using an
- # unmanaged toolbar in your frame
- return self.toolbar
-
- def onTimer(self, evt):
- self.count += 1
- if self.count >= 60: self.count = 0
- self.lines[0].set_data(self.ind, self.X[:,self.count])
- self.canvas.draw()
- self.canvas.gui_repaint()
-
-if __name__ == '__main__':
- app = PySimpleApp()
- frame = PlotFigure()
- frame.init_plot_data()
-
- # Initialise the timer - wxPython requires this to be connected to the
- # receivicng event handler
- t = Timer(frame, TIMER_ID)
- t.Start(100)
-
- frame.Show()
- app.MainLoop()
Modified: trunk/matplotlib/examples/user_interfaces/embedding_in_wx4.py
===================================================================
--- trunk/matplotlib/examples/user_interfaces/embedding_in_wx4.py 2008-06-24 18:06:22 UTC (rev 5666)
+++ trunk/matplotlib/examples/user_interfaces/embedding_in_wx4.py 2008-06-24 18:13:40 UTC (rev 5667)
@@ -8,11 +8,6 @@
import matplotlib
-# uncomment the following to use wx rather than wxagg
-#matplotlib.use('WX')
-#from matplotlib.backends.backend_wx import FigureCanvasWx as FigureCanvas
-
-# comment out the following to use wx rather than wxagg
matplotlib.use('WXAgg')
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas
from matplotlib.backends.backend_wxagg import NavigationToolbar2WxAgg
Modified: trunk/matplotlib/lib/matplotlib/__init__.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/__init__.py 2008-06-24 18:06:22 UTC (rev 5666)
+++ trunk/matplotlib/lib/matplotlib/__init__.py 2008-06-24 18:13:40 UTC (rev 5667)
@@ -89,7 +89,7 @@
"""
from __future__ import generators
-__version__ = '0.98.1'
+__version__ = '0.98.2'
__revision__ = '$Revision$'
__date__ = '$Date$'
Modified: trunk/matplotlib/lib/matplotlib/artist.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/artist.py 2008-06-24 18:06:22 UTC (rev 5666)
+++ trunk/matplotlib/lib/matplotlib/artist.py 2008-06-24 18:13:40 UTC (rev 5667)
@@ -690,37 +690,43 @@
return lines
-def getp(o, *args):
+def getp(o, property=None):
"""
- .. TODO: What are 's' and 'h' arguments described below?
+ Return the value of handle property. property is an optional string
+ for the property you want to return
- Return the value of handle property s
+ Example usage::
- h is an instance of a class, eg a Line2D or an Axes or Text.
- if s is 'somename', this function returns
+ getp(o) # get all the object properties
+ getp(o, 'linestyle') # get the linestyle property
+
+ o is a :class:`Artist` instance, eg
+ :class:`~matplotllib.lines.Line2D` or an instance of a
+ :class:`~matplotlib.axes.Axes` or :class:`matplotlib.text.Text`.
+ If the *property* is 'somename', this function returns
+
o.get_somename()
getp can be used to query all the gettable properties with getp(o)
Many properties have aliases for shorter typing, eg 'lw' is an
alias for 'linewidth'. In the output, aliases and full property
- names will be listed as:
+ names will be listed as::
property or alias = value
- e.g.:
+ e.g.::
linewidth or lw = 2
"""
insp = ArtistInspector(o)
- if len(args)==0:
+ if property is None:
print '\n'.join(insp.pprint_getters())
return
- name = args[0]
- func = getattr(o, 'get_' + name)
+ func = getattr(o, 'get_' + property)
return func()
def get(o, *args, **kwargs):
Modified: trunk/matplotlib/lib/matplotlib/scale.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/scale.py 2008-06-24 18:06:22 UTC (rev 5666)
+++ trunk/matplotlib/lib/matplotlib/scale.py 2008-06-24 18:13:40 UTC (rev 5667)
@@ -178,10 +178,8 @@
*subsx*/*subsy*:
Where to place the subticks between each major tick.
Should be a sequence of integers. For example, in a log10
- scale::
+ scale: ``[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]``
- [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
-
will place 10 logarithmically spaced minor ticks between
each major tick.
"""
@@ -291,10 +289,8 @@
*subsx*/*subsy*:
Where to place the subticks between each major tick.
Should be a sequence of integers. For example, in a log10
- scale::
+ scale: ``[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]``
- [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
-
will place 10 logarithmically spaced minor ticks between
each major tick.
"""
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2008-06-24 19:15:22
|
Revision: 5670
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5670&view=rev
Author: jdh2358
Date: 2008-06-24 12:15:20 -0700 (Tue, 24 Jun 2008)
Log Message:
-----------
use plain text rather than text image for watermark example
Modified Paths:
--------------
trunk/matplotlib/doc/devel/release_guide.rst
trunk/matplotlib/examples/api/watermark_text.py
Modified: trunk/matplotlib/doc/devel/release_guide.rst
===================================================================
--- trunk/matplotlib/doc/devel/release_guide.rst 2008-06-24 18:58:41 UTC (rev 5669)
+++ trunk/matplotlib/doc/devel/release_guide.rst 2008-06-24 19:15:20 UTC (rev 5670)
@@ -55,10 +55,17 @@
* ftp the source and binaries to the anonymous FTP site::
- local> cd dist
- local> ncftp upload.sourceforge.net
- ncftp> cd incoming
- ncftp> put tar.gz, zip exe
+ mpl> svn-clean
+ mpl> python setup.py sdist
+ mpl> cd dist/
+ dist> sftp jd...@fr...
+ Connecting to frs.sourceforge.net...
+ sftp> cd uploads
+ sftp> ls
+ sftp> lls
+ matplotlib-0.98.2.tar.gz
+ sftp> put matplotlib-0.98.2.tar.gz
+ Uploading matplotlib-0.98.2.tar.gz to /incoming/j/jd/jdh2358/uploads/matplotlib-0.98.2.tar.gz
* go https://sourceforge.net/project/admin/?group_id=80706 and do a
file release. Click on the "Admin" tab to log in as an admin, and
Modified: trunk/matplotlib/examples/api/watermark_text.py
===================================================================
--- trunk/matplotlib/examples/api/watermark_text.py 2008-06-24 18:58:41 UTC (rev 5669)
+++ trunk/matplotlib/examples/api/watermark_text.py 2008-06-24 19:15:20 UTC (rev 5670)
@@ -1,34 +1,22 @@
"""
-Use a PNG file as a watermark
+Use a Text as a watermark
"""
import numpy as np
import matplotlib
matplotlib.use('Agg')
-import matplotlib.mathtext as mathtext
import matplotlib.pyplot as plt
-import matplotlib
-matplotlib.rc('image', origin='upper')
-dpi = 100 # save dpi
-w, h = 8, 6 # inches
+fig = plt.figure()
-parser = mathtext.MathTextParser("Bitmap")
-
-rgba, depth1 = parser.to_rgba(r'Property of MPL', color='gray',
- fontsize=30, dpi=200)
-rgba[:,:,-1] *= 0.5
-fig = plt.figure(figsize=(w,h))
-
ax = fig.add_subplot(111)
ax.plot(np.random.rand(20), '-o', ms=20, lw=2, alpha=0.7, mfc='orange')
ax.grid()
-imh, imw, tmp = rgba.shape
+# position bottom right
+fig.text(0.95, 0.05, 'Property of MPL',
+ fontsize=50, color='gray',
+ ha='right', va='bottom', alpha=0.5)
-# position image at bottom right
-fig.figimage(rgba.astype(float)/255., w*dpi-imw, 0)
+fig.savefig('watermarked_text', transparent=True)
-
-fig.savefig('watermarked_text', transparent=True, dpi=dpi)
-
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2008-06-25 12:50:19
|
Revision: 5671
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5671&view=rev
Author: mdboom
Date: 2008-06-25 05:49:57 -0700 (Wed, 25 Jun 2008)
Log Message:
-----------
Fix rendering quality of pcolor.
Modified Paths:
--------------
trunk/matplotlib/CHANGELOG
trunk/matplotlib/lib/matplotlib/axes.py
trunk/matplotlib/lib/matplotlib/collections.py
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2008-06-24 19:15:20 UTC (rev 5670)
+++ trunk/matplotlib/CHANGELOG 2008-06-25 12:49:57 UTC (rev 5671)
@@ -1,9 +1,11 @@
+2008-06-25 Fix rendering quality of pcolor - MGD
+
=================================================================
-2006-02-24 Released 0.98.2 at svn r5667 - (source only for debian) JDH
+2008-06-24 Released 0.98.2 at svn r5667 - (source only for debian) JDH
-2006-06-24 Added "transparent" kwarg to savefig. - MGD
+2008-06-24 Added "transparent" kwarg to savefig. - MGD
-2006-06-24 Applied Stefan's patch to draw a sinle centered marker over
+2008-06-24 Applied Stefan's patch to draw a sinle centered marker over
a line with numpoints==1 - JDH
2008-06-23 Use splines to render circles in scatter plots - MGD
Modified: trunk/matplotlib/lib/matplotlib/axes.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/axes.py 2008-06-24 19:15:20 UTC (rev 5670)
+++ trunk/matplotlib/lib/matplotlib/axes.py 2008-06-25 12:49:57 UTC (rev 5671)
@@ -5563,8 +5563,8 @@
edgecolors = (0,0,0,1),
linewidths = (0.25,)
else:
- edgecolors = 'None'
- linewidths = (0.0,)
+ edgecolors = 'face'
+ linewidths = (1.0,)
kwargs.setdefault('edgecolors', edgecolors)
kwargs.setdefault('antialiaseds', (0,))
kwargs.setdefault('linewidths', linewidths)
@@ -5607,8 +5607,8 @@
*C* may be a masked array, but *X* and *Y* may not. Masked
array support is implemented via *cmap* and *norm*; in
- contrast, *pcolor* simply does not draw quadrilaterals with
- masked colors or vertices.
+ contrast, :func:`~matplotlib.pyplot.pcolor` simply does not
+ draw quadrilaterals with masked colors or vertices.
Keyword arguments:
@@ -5646,7 +5646,7 @@
*alpha*: 0 <= scalar <= 1
the alpha blending value
- Return value is a :class:`matplotlib.collection.Collection`
+ Return value is a :class:`matplotlib.collection.QuadMesh`
object.
See :func:`~matplotlib.pyplot.pcolor` for an explanation of
Modified: trunk/matplotlib/lib/matplotlib/collections.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/collections.py 2008-06-24 19:15:20 UTC (rev 5670)
+++ trunk/matplotlib/lib/matplotlib/collections.py 2008-06-25 12:49:57 UTC (rev 5671)
@@ -184,11 +184,16 @@
offsets = transOffset.transform_non_affine(offsets)
transOffset = transOffset.get_affine()
+ if self._edgecolors == 'face':
+ edgecolors = self._facecolors
+ else:
+ edgecolors = self._edgecolors
+
renderer.draw_path_collection(
transform.frozen(), self.clipbox, clippath, clippath_trans,
paths, self.get_transforms(),
offsets, transOffset,
- self._facecolors, self._edgecolors, self._linewidths,
+ self._facecolors, edgecolors, self._linewidths,
self._linestyles, self._antialiaseds)
renderer.close_group(self.__class__.__name__)
@@ -318,12 +323,18 @@
Set the edgecolor(s) of the collection. *c* can be a
matplotlib color arg (all patches have same color), or a
sequence or rgba tuples; if it is a sequence the patches will
- cycle through the sequence
+ cycle through the sequence.
+ If *c* is 'face', the edge color will always be the same as
+ the face color.
+
ACCEPTS: matplotlib color arg or sequence of rgba tuples
"""
- if c is None: c = mpl.rcParams['patch.edgecolor']
- self._edgecolors = _colors.colorConverter.to_rgba_array(c, self._alpha)
+ if c == 'face':
+ self._edgecolors = 'face'
+ else:
+ if c is None: c = mpl.rcParams['patch.edgecolor']
+ self._edgecolors = _colors.colorConverter.to_rgba_array(c, self._alpha)
set_edgecolors = set_edgecolor
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2008-06-25 22:03:39
|
Revision: 5674
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5674&view=rev
Author: jdh2358
Date: 2008-06-25 15:03:15 -0700 (Wed, 25 Jun 2008)
Log Message:
-----------
renamed axesPatch, axesFrame and figurePatch to be less redundant
Modified Paths:
--------------
trunk/matplotlib/API_CHANGES
trunk/matplotlib/CHANGELOG
trunk/matplotlib/doc/faq/howto_faq.rst
trunk/matplotlib/doc/pyplots/fig_axes_customize_simple.py
trunk/matplotlib/doc/users/artists.rst
trunk/matplotlib/examples/api/logo2.py
trunk/matplotlib/examples/pylab_examples/set_and_get.py
trunk/matplotlib/lib/matplotlib/axes.py
trunk/matplotlib/lib/matplotlib/figure.py
trunk/matplotlib/lib/matplotlib/image.py
Modified: trunk/matplotlib/API_CHANGES
===================================================================
--- trunk/matplotlib/API_CHANGES 2008-06-25 21:43:09 UTC (rev 5673)
+++ trunk/matplotlib/API_CHANGES 2008-06-25 22:03:15 UTC (rev 5674)
@@ -1,3 +1,10 @@
+Changes for 0.98.x
+==================
+
+* Figure.figurePatch renamed Figure.patch, Axes.axesPatch renamed
+ Axes.patch, Axes.axesFrame renamed Axes.frame, Axes.get_frame, which
+ returns Axes.patch, is deprecated. Examples and users guide updated
+
Changes for 0.98.1
==================
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2008-06-25 21:43:09 UTC (rev 5673)
+++ trunk/matplotlib/CHANGELOG 2008-06-25 22:03:15 UTC (rev 5674)
@@ -1,3 +1,8 @@
+2008-06-25 Figure.figurePatch renamed Figure.patch, Axes.axesPatch
+ renamed Axes.patch, Axes.axesFrame renamed Axes.frame,
+ Axes.get_frame, which returns Axes.patch, is deprecated.
+ Examples and users guide updated - JDH
+
2008-06-25 Fix rendering quality of pcolor - MGD
=================================================================
Modified: trunk/matplotlib/doc/faq/howto_faq.rst
===================================================================
--- trunk/matplotlib/doc/faq/howto_faq.rst 2008-06-25 21:43:09 UTC (rev 5673)
+++ trunk/matplotlib/doc/faq/howto_faq.rst 2008-06-25 22:03:15 UTC (rev 5674)
@@ -17,15 +17,15 @@
image on the screen. If you need finer grained control, eg you do not
want full transparency or you to affect the screen displayed version
as well, you can set the alpha properties directly. The figure has a
-:class:`matplotlib.patches.Rectangle` instance called *figurePatch*
-and the axes has a Rectangle instance called *axesPatch*. You can set
+:class:`matplotlib.patches.Rectangle` instance called *patch*
+and the axes has a Rectangle instance called *patch*. You can set
any property on them directly (*facecolor*, *edgecolor*, *linewidth*,
*linestyle*, *alpha*). Eg::
fig = plt.figure()
- fig.figurePatch.set_alpha(0.5)
+ fig.patch.set_alpha(0.5)
ax = fig.add_subplot(111)
- ax.axesPatch.set_alpha(0.5)
+ ax.patch.set_alpha(0.5)
If you need *all* the figure elements to be transparent, there is
currently no global alpha setting, but you can set the alpha channel
Modified: trunk/matplotlib/doc/pyplots/fig_axes_customize_simple.py
===================================================================
--- trunk/matplotlib/doc/pyplots/fig_axes_customize_simple.py 2008-06-25 21:43:09 UTC (rev 5673)
+++ trunk/matplotlib/doc/pyplots/fig_axes_customize_simple.py 2008-06-25 22:03:15 UTC (rev 5674)
@@ -3,11 +3,11 @@
# plt.figure creates a matplotlib.figure.Figure instance
fig = plt.figure()
-rect = fig.figurePatch # a rectangle instance
+rect = fig.patch # a rectangle instance
rect.set_facecolor('lightgoldenrodyellow')
ax1 = fig.add_axes([0.1, 0.3, 0.4, 0.4])
-rect = ax1.axesPatch
+rect = ax1.patch
rect.set_facecolor('lightslategray')
Modified: trunk/matplotlib/doc/users/artists.rst
===================================================================
--- trunk/matplotlib/doc/users/artists.rst 2008-06-25 21:43:09 UTC (rev 5673)
+++ trunk/matplotlib/doc/users/artists.rst 2008-06-25 22:03:15 UTC (rev 5674)
@@ -151,9 +151,9 @@
(the standard white box with black edges in the typical matplotlib
plot, has a ``Rectangle`` instance that determines the color,
transparency, and other properties of the Axes. These instances are
-stored as member variables :attr:`Figure.figurePatch
-<matplotlib.figure.Figure.figurePatch>` and :attr:`Axes.axesPatch
-<matplotlib.axes.Axes.axesPatch>` ("Patch" is a name inherited from
+stored as member variables :attr:`Figure.patch
+<matplotlib.figure.Figure.patch>` and :attr:`Axes.patch
+<matplotlib.axes.Axes.patch>` ("Patch" is a name inherited from
MATLAB™, and is a 2D "patch" of color on the figure, eg. rectangles,
circles and polygons). Every matplotlib ``Artist`` has the following
properties
@@ -199,7 +199,7 @@
.. sourcecode:: ipython
- In [149]: matplotlib.artist.getp(fig.figurePatch)
+ In [149]: matplotlib.artist.getp(fig.patch)
alpha = 1.0
animated = False
antialiased or aa = True
@@ -261,7 +261,7 @@
:class:`matplotlib.figure.Figure`, and it contains everything in the
figure. The background of the figure is a
:class:`~matplotlib.patches.Rectangle` which is stored in
-:attr:`Figure.figurePatch <matplotlib.figure.Figure.figurePatch>`. As
+:attr:`Figure.patch <matplotlib.figure.Figure.patch>`. As
you add subplots (:meth:`~matplotlib.figure.Figure.add_subplot`) and
axes (:meth:`~matplotlib.figure.Figure.add_axes`) to the figure
these will be appended to the :attr:`Figure.axes
@@ -336,7 +336,7 @@
Figure attribute Description
================ ===============================================================
axes A list of Axes instances (includes Subplot)
-figurePatch The Rectangle background
+patch The Rectangle background
images A list of FigureImages patches - useful for raw pixel display
legends A list of Figure Legend instances (different from Axes.legends)
lines A list of Figure Line2D instances (rarely used, see Axes.lines)
@@ -356,13 +356,13 @@
customize the ``Artists`` it contains. Like the
:class:`~matplotlib.figure.Figure`, it contains a
:class:`~matplotlib.patches.Patch`
-:attr:`~matplotlib.axes.Axes.axesPatch` which is a
+:attr:`~matplotlib.axes.Axes.patch` which is a
:class:`~matplotlib.patches.Rectangle` for Cartesian coordinates and a
:class:`~matplotlib.patches.Circle` for polar coordinates; this patch
determines the shape, background and border of the plotting region::
ax = fig.add_subplot(111)
- rect = ax.axesPatch # a Rectangle instance
+ rect = ax.patch # a Rectangle instance
rect.set_facecolor('green')
When you call a plotting method, eg. the canonical
@@ -511,7 +511,7 @@
Axes attribute Description
============== ======================================
artists A list of Artist instances
-axesPatch Rectangle instance for Axes background
+patch Rectangle instance for Axes background
collections A list of Collection instances
images A list of AxesImage
legends A list of Legend instances
Modified: trunk/matplotlib/examples/api/logo2.py
===================================================================
--- trunk/matplotlib/examples/api/logo2.py 2008-06-25 21:43:09 UTC (rev 5673)
+++ trunk/matplotlib/examples/api/logo2.py 2008-06-25 22:03:15 UTC (rev 5674)
@@ -7,12 +7,12 @@
figcolor = '#FFFFCC'
dpi = 80
fig = plt.figure(figsize=(8, 2),dpi=dpi)
-fig.figurePatch.set_edgecolor(figcolor)
-fig.figurePatch.set_facecolor(figcolor)
+fig.patch.set_edgecolor(figcolor)
+fig.patch.set_facecolor(figcolor)
# the polar bar plot
ax = fig.add_axes([0.05, 0.05, 0.2, 01], polar=True)
-ax.axesPatch.set_alpha(axalpha)
+ax.patch.set_alpha(axalpha)
N = 20
theta = np.arange(0.0, 2*np.pi, 2*np.pi/N) + np.pi
radii = 10*np.random.rand(N)
@@ -31,7 +31,7 @@
# the histogram
axhist = fig.add_axes([0.275, 0.075, 0.2, 0.4])
-axhist.axesPatch.set_alpha(axalpha)
+axhist.patch.set_alpha(axalpha)
mu, sigma = 100, 15
x = mu + sigma*np.random.randn(10000)
Modified: trunk/matplotlib/examples/pylab_examples/set_and_get.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/set_and_get.py 2008-06-25 21:43:09 UTC (rev 5673)
+++ trunk/matplotlib/examples/pylab_examples/set_and_get.py 2008-06-25 22:03:15 UTC (rev 5674)
@@ -83,9 +83,9 @@
getp(l1)
print 'Rectangle setters'
-setp(gca().axesPatch)
+setp(gca().patch)
print 'Rectangle getters'
-getp(gca().axesPatch)
+getp(gca().patch)
t = title('Hi mom')
print 'Text setters'
Modified: trunk/matplotlib/lib/matplotlib/axes.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/axes.py 2008-06-25 21:43:09 UTC (rev 5673)
+++ trunk/matplotlib/lib/matplotlib/axes.py 2008-06-25 22:03:15 UTC (rev 5674)
@@ -815,7 +815,7 @@
a.set_transform(self.transData)
a.axes = self
- def get_axes_patch(self):
+ def _gen_axes_patch(self):
"""
Returns the patch used to draw the background of the axes. It
is also used as the clipping path for any data elements on the
@@ -878,24 +878,30 @@
self._set_artist_props(self.title)
- self.axesPatch = self.get_axes_patch()
- self.axesPatch.set_figure(self.figure)
- self.axesPatch.set_facecolor(self._axisbg)
- self.axesPatch.set_edgecolor(rcParams['axes.edgecolor'])
- self.axesPatch.set_linewidth(rcParams['axes.linewidth'])
- self.axesPatch.set_transform(self.transAxes)
+ # the patch draws the background of the axes. we want this to
+ # be below the other artists; the axesPatch name is deprecated
+ self.patch = self.axesPatch = self._gen_axes_patch()
+ self.patch.set_figure(self.figure)
+ self.patch.set_facecolor(self._axisbg)
+ self.patch.set_edgecolor(rcParams['axes.edgecolor'])
+ self.patch.set_linewidth(rcParams['axes.linewidth'])
+ self.patch.set_transform(self.transAxes)
- self.axesFrame = self.get_axes_patch()
- self.axesFrame.set_figure(self.figure)
- self.axesFrame.set_facecolor('none')
- self.axesFrame.set_edgecolor(rcParams['axes.edgecolor'])
- self.axesFrame.set_linewidth(rcParams['axes.linewidth'])
- self.axesFrame.set_transform(self.transAxes)
- self.axesFrame.set_zorder(2.5)
+ # the frame draws the border around the axes and we want this
+ # above. this is a place holder for a more sophisticated
+ # artist that might just draw a left, bottom frame, or a
+ # centered frame, etc the axesFrame name is deprecated
+ self.frame = self.axesFrame = self._gen_axes_patch()
+ self.frame.set_figure(self.figure)
+ self.frame.set_facecolor('none')
+ self.frame.set_edgecolor(rcParams['axes.edgecolor'])
+ self.frame.set_linewidth(rcParams['axes.linewidth'])
+ self.frame.set_transform(self.transAxes)
+ self.frame.set_zorder(2.5)
self.axison = True
- self.xaxis.set_clip_path(self.axesPatch)
- self.yaxis.set_clip_path(self.axesPatch)
+ self.xaxis.set_clip_path(self.patch)
+ self.yaxis.set_clip_path(self.patch)
def clear(self):
@@ -1211,7 +1217,8 @@
def get_frame(self):
'Return the axes Rectangle frame'
- return self.axesPatch
+ warnings.warn('use ax.patch instead', DeprecationWarning)
+ return self.patch
def get_legend(self):
'Return the legend.Legend instance, or None if no legend is defined'
@@ -1271,7 +1278,7 @@
a.set_axes(self)
self.artists.append(a)
self._set_artist_props(a)
- a.set_clip_path(self.axesPatch)
+ a.set_clip_path(self.patch)
a._remove_method = lambda h: self.artists.remove(h)
def add_collection(self, collection, autolim=True):
@@ -1284,7 +1291,7 @@
collection.set_label('collection%d'%len(self.collections))
self.collections.append(collection)
self._set_artist_props(collection)
- collection.set_clip_path(self.axesPatch)
+ collection.set_clip_path(self.patch)
if autolim:
if collection._paths and len(collection._paths):
self.update_datalim(collection.get_datalim(self.transData))
@@ -1296,7 +1303,7 @@
lines
'''
self._set_artist_props(line)
- line.set_clip_path(self.axesPatch)
+ line.set_clip_path(self.patch)
self._update_line_limits(line)
if not line.get_label():
@@ -1317,7 +1324,7 @@
"""
self._set_artist_props(p)
- p.set_clip_path(self.axesPatch)
+ p.set_clip_path(self.patch)
self._update_patch_limits(p)
self.patches.append(p)
p._remove_method = lambda h: self.patches.remove(h)
@@ -1345,7 +1352,7 @@
'''
self._set_artist_props(tab)
self.tables.append(tab)
- tab.set_clip_path(self.axesPatch)
+ tab.set_clip_path(self.patch)
tab._remove_method = lambda h: self.tables.remove(h)
def relim(self):
@@ -1419,7 +1426,7 @@
return *True* if the given *mouseevent* (in display coords)
is in the Axes
'''
- return self.axesPatch.contains(mouseevent)[0]
+ return self.patch.contains(mouseevent)[0]
def get_autoscale_on(self):
"""
@@ -1475,7 +1482,7 @@
self.apply_aspect(self.get_position(True))
if self.axison and self._frameon:
- self.axesPatch.draw(renderer)
+ self.patch.draw(renderer)
artists = []
@@ -1508,8 +1515,8 @@
# respect z-order for now
renderer.draw_image(
round(l), round(b), im, self.bbox,
- self.axesPatch.get_path(),
- self.axesPatch.get_transform())
+ self.patch.get_path(),
+ self.patch.get_transform())
artists.extend(self.collections)
artists.extend(self.patches)
@@ -1529,7 +1536,7 @@
if self.legend_ is not None:
artists.append(self.legend_)
if self.axison and self._frameon:
- artists.append(self.axesFrame)
+ artists.append(self.frame)
dsu = [ (a.zorder, i, a) for i, a in enumerate(artists)
if not a.get_animated() ]
@@ -1696,7 +1703,7 @@
"""
self._axisbg = color
- self.axesPatch.set_facecolor(color)
+ self.patch.set_facecolor(color)
### data limits, ticks, tick labels, and formatting
@@ -2364,8 +2371,8 @@
children.append(self.legend_)
children.extend(self.collections)
children.append(self.title)
- children.append(self.axesPatch)
- children.append(self.axesFrame)
+ children.append(self.patch)
+ children.append(self.frame)
return children
def contains(self,mouseevent):
@@ -2375,7 +2382,7 @@
"""
if callable(self._contains): return self._contains(self,mouseevent)
- inside = self.axesPatch.contains(mouseevent.x, mouseevent.y)
+ inside = self.patch.contains(mouseevent.x, mouseevent.y)
return inside,{}
def pick(self, *args):
@@ -2647,7 +2654,7 @@
a = mtext.Annotation(*args, **kwargs)
a.set_transform(mtransforms.IdentityTransform())
self._set_artist_props(a)
- if kwargs.has_key('clip_on'): a.set_clip_path(self.axesPatch)
+ if kwargs.has_key('clip_on'): a.set_clip_path(self.patch)
self.texts.append(a)
return a
annotate.__doc__ = cbook.dedent(annotate.__doc__) % martist.kwdocd
@@ -5342,7 +5349,7 @@
im.set_data(X)
im.set_alpha(alpha)
self._set_artist_props(im)
- im.set_clip_path(self.axesPatch)
+ im.set_clip_path(self.patch)
#if norm is None and shape is None:
# im.set_clim(vmin, vmax)
if vmin is not None or vmax is not None:
Modified: trunk/matplotlib/lib/matplotlib/figure.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/figure.py 2008-06-25 21:43:09 UTC (rev 5673)
+++ trunk/matplotlib/lib/matplotlib/figure.py 2008-06-25 22:03:15 UTC (rev 5674)
@@ -209,7 +209,7 @@
The figure patch is drawn by a the attribute
- *figurePatch*
+ *patch*
a :class:`matplotlib.patches.Rectangle` instance
*suppressComposite*
@@ -265,12 +265,13 @@
self.transFigure = BboxTransformTo(self.bbox)
- self.figurePatch = Rectangle(
+ # the figurePatch name is deprecated
+ self.patch = self.figurePatch = Rectangle(
xy=(0,0), width=1, height=1,
facecolor=facecolor, edgecolor=edgecolor,
linewidth=linewidth,
)
- self._set_artist_props(self.figurePatch)
+ self._set_artist_props(self.patch)
self._hold = rcParams['axes.hold']
self.canvas = None
@@ -331,7 +332,7 @@
def get_children(self):
'get a list of artists contained in the figure'
- children = [self.figurePatch]
+ children = [self.patch]
children.extend(self.artists)
children.extend(self.axes)
children.extend(self.lines)
@@ -527,11 +528,11 @@
def get_edgecolor(self):
'Get the edge color of the Figure rectangle'
- return self.figurePatch.get_edgecolor()
+ return self.patch.get_edgecolor()
def get_facecolor(self):
'Get the face color of the Figure rectangle'
- return self.figurePatch.get_facecolor()
+ return self.patch.get_facecolor()
def get_figwidth(self):
'Return the figwidth as a float'
@@ -555,7 +556,7 @@
ACCEPTS: any matplotlib color - see help(colors)
"""
- self.figurePatch.set_edgecolor(color)
+ self.patch.set_edgecolor(color)
def set_facecolor(self, color):
"""
@@ -563,7 +564,7 @@
ACCEPTS: any matplotlib color - see help(colors)
"""
- self.figurePatch.set_facecolor(color)
+ self.patch.set_facecolor(color)
def set_dpi(self, val):
"""
@@ -795,7 +796,7 @@
if not self.get_visible(): return
renderer.open_group('figure')
- if self.frameon: self.figurePatch.draw(renderer)
+ if self.frameon: self.patch.draw(renderer)
# todo: respect zorder
for p in self.patches: p.draw(renderer)
@@ -1022,20 +1023,20 @@
transparent = kwargs.pop('transparent', False)
if transparent:
- original_figure_alpha = self.figurePatch.get_alpha()
- self.figurePatch.set_alpha(0.0)
+ original_figure_alpha = self.patch.get_alpha()
+ self.patch.set_alpha(0.0)
original_axes_alpha = []
for ax in self.axes:
- axesPatch = ax.get_frame()
- original_axes_alpha.append(axesPatch.get_alpha())
- axesPatch.set_alpha(0.0)
+ patch = ax.patch
+ original_axes_alpha.append(patch.get_alpha())
+ patch.set_alpha(0.0)
self.canvas.print_figure(*args, **kwargs)
if transparent:
- self.figurePatch.set_alpha(original_figure_alpha)
+ self.patch.set_alpha(original_figure_alpha)
for ax, alpha in zip(self.axes, original_axes_alpha):
- ax.get_frame().set_alpha(alpha)
+ ax.patch.set_alpha(alpha)
def colorbar(self, mappable, cax=None, ax=None, **kw):
if ax is None:
Modified: trunk/matplotlib/lib/matplotlib/image.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/image.py 2008-06-25 21:43:09 UTC (rev 5673)
+++ trunk/matplotlib/lib/matplotlib/image.py 2008-06-25 22:03:15 UTC (rev 5674)
@@ -193,7 +193,7 @@
else:
im = self._imcache
- fc = self.axes.get_frame().get_facecolor()
+ fc = self.axes.patch.get_facecolor()
bg = mcolors.colorConverter.to_rgba(fc, 0)
im.set_bg( *bg)
@@ -400,7 +400,7 @@
im = _image.pcolor(self._Ax, self._Ay, self._A,
height, width,
(x0, x0+v_width, y0, y0+v_height))
- fc = self.axes.get_frame().get_facecolor()
+ fc = self.axes.patch.get_facecolor()
bg = mcolors.colorConverter.to_rgba(fc, 0)
im.set_bg(*bg)
return im
@@ -500,7 +500,7 @@
def make_image(self, magnification=1.0):
if self._A is None:
raise RuntimeError('You must first set the image array')
- fc = self.axes.get_frame().get_facecolor()
+ fc = self.axes.patch.get_facecolor()
bg = mcolors.colorConverter.to_rgba(fc, 0)
bg = (np.array(bg)*255).astype(np.uint8)
l, b, r, t = self.axes.bbox.extents
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2008-06-26 12:32:34
|
Revision: 5676
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5676&view=rev
Author: mdboom
Date: 2008-06-26 05:32:32 -0700 (Thu, 26 Jun 2008)
Log Message:
-----------
Merged revisions 5635-5675 via svnmerge from
https://matplotlib.svn.sf.net/svnroot/matplotlib/branches/v0_91_maint
........
r5638 | cmoad | 2008-06-22 22:11:08 -0400 (Sun, 22 Jun 2008) | 1 line
minor rev bump
........
r5675 | mdboom | 2008-06-26 08:28:48 -0400 (Thu, 26 Jun 2008) | 2 lines
Fix direction of horizontal and vertical hatching.
........
Modified Paths:
--------------
trunk/matplotlib/CHANGELOG
trunk/matplotlib/lib/matplotlib/backends/backend_ps.py
Property Changed:
----------------
trunk/matplotlib/
Property changes on: trunk/matplotlib
___________________________________________________________________
Name: svnmerge-integrated
- /branches/v0_91_maint:1-5635
+ /branches/v0_91_maint:1-5675
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2008-06-26 12:28:48 UTC (rev 5675)
+++ trunk/matplotlib/CHANGELOG 2008-06-26 12:32:32 UTC (rev 5676)
@@ -1,3 +1,5 @@
+2008-06-26 Fix direction of horizontal/vertical hatches - MGD
+
2008-06-25 Figure.figurePatch renamed Figure.patch, Axes.axesPatch
renamed Axes.patch, Axes.axesFrame renamed Axes.frame,
Axes.get_frame, which returns Axes.patch, is deprecated.
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_ps.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_ps.py 2008-06-26 12:28:48 UTC (rev 5675)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_ps.py 2008-06-26 12:32:32 UTC (rev 5676)
@@ -254,12 +254,12 @@
hatchr cvi hatchgap idiv hatchgap mul
{hatcht m 0 hatchb hatcht sub r }
for
- stroke
+ strokeCHAN
grestore
""" % (angle, 12/density)
self._pswriter.write("gsave\n")
- self._pswriter.write(do_hatch(0, hatches['horiz']))
- self._pswriter.write(do_hatch(90, hatches['vert']))
+ self._pswriter.write(do_hatch(90, hatches['horiz']))
+ self._pswriter.write(do_hatch(0, hatches['vert']))
self._pswriter.write(do_hatch(45, hatches['diag1']))
self._pswriter.write(do_hatch(-45, hatches['diag2']))
self._pswriter.write("grestore\n")
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2008-06-26 12:39:36
|
Revision: 5678
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5678&view=rev
Author: mdboom
Date: 2008-06-26 05:39:30 -0700 (Thu, 26 Jun 2008)
Log Message:
-----------
Merged revisions 5676-5677 via svnmerge from
https://matplotlib.svn.sf.net/svnroot/matplotlib/branches/v0_91_maint
........
r5677 | mdboom | 2008-06-26 08:36:15 -0400 (Thu, 26 Jun 2008) | 1 line
Oops in last commit
........
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/backends/backend_ps.py
Property Changed:
----------------
trunk/matplotlib/
Property changes on: trunk/matplotlib
___________________________________________________________________
Name: svnmerge-integrated
- /branches/v0_91_maint:1-5675
+ /branches/v0_91_maint:1-5677
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_ps.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_ps.py 2008-06-26 12:36:15 UTC (rev 5677)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_ps.py 2008-06-26 12:39:30 UTC (rev 5678)
@@ -254,7 +254,7 @@
hatchr cvi hatchgap idiv hatchgap mul
{hatcht m 0 hatchb hatcht sub r }
for
- strokeCHAN
+ stroke
grestore
""" % (angle, 12/density)
self._pswriter.write("gsave\n")
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2008-06-26 18:05:18
|
Revision: 5681
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5681&view=rev
Author: mdboom
Date: 2008-06-26 11:05:17 -0700 (Thu, 26 Jun 2008)
Log Message:
-----------
Include some examples inline in the api docs.
Modified Paths:
--------------
trunk/matplotlib/doc/sphinxext/plot_directive.py
trunk/matplotlib/lib/matplotlib/axes.py
Modified: trunk/matplotlib/doc/sphinxext/plot_directive.py
===================================================================
--- trunk/matplotlib/doc/sphinxext/plot_directive.py 2008-06-26 17:47:04 UTC (rev 5680)
+++ trunk/matplotlib/doc/sphinxext/plot_directive.py 2008-06-26 18:05:17 UTC (rev 5681)
@@ -13,7 +13,7 @@
source will be included inline, as well as a link to the source.
"""
-import sys, os, glob
+import sys, os, glob, shutil
from docutils.parsers.rst import directives
try:
@@ -40,29 +40,10 @@
'class': directives.class_option,
'include-source': directives.flag }
-template_no_source = """
+template = """
.. htmlonly::
- [ `<../%(srcdir)s/%(reference)s>`__,
- `png <../%(srcdir)s/%(basename)s.hires.png>`__,
- `pdf <../%(srcdir)s/%(basename)s.pdf>`__]
-
- .. image:: ../%(srcdir)s/%(basename)s.png
-%(options)s
-
-
-.. latexonly::
- .. image:: ../%(srcdir)s/%(basename)s.pdf
-%(options)s
-
-"""
-
-template_source = """
-.. literalinclude:: ../pyplots/%(reference)s
-
-.. htmlonly::
-
- [ `py <../%(srcdir)s/%(reference)s>`__,
+ [`py <../%(srcdir)s/%(basename)s.py>`__,
`png <../%(srcdir)s/%(basename)s.hires.png>`__,
`pdf <../%(srcdir)s/%(basename)s.pdf>`__]
@@ -90,6 +71,9 @@
basename, ext = os.path.splitext(fname)
all_exists = True
+ if basedir != outdir:
+ shutil.copyfile(fullpath, os.path.join(outdir, fname))
+
for format, dpi in formats:
outname = os.path.join(outdir, '%s.%s' % (basename, format))
if not os.path.exists(outname):
@@ -109,10 +93,10 @@
if os.path.exists(outname): continue
plt.savefig(outname, dpi=dpi)
-
def run(arguments, options, state_machine, lineno):
reference = directives.uri(arguments[0])
- basename, ext = os.path.splitext(reference)
+ basedir, fname = os.path.split(reference)
+ basename, ext = os.path.splitext(fname)
# todo - should we be using the _static dir for the outdir, I am
# not sure we want to corrupt that dir with autogenerated files
@@ -126,16 +110,16 @@
# the figs into the right place, so we may want to do that here instead.
if options.has_key('include-source'):
- template = template_source
+ lines = ['.. literalinclude:: ../pyplots/%(reference)s' % locals()]
del options['include-source']
else:
- template = template_no_source
+ lines = []
+
options = [' :%s: %s' % (key, val) for key, val in
options.items()]
options = "\n".join(options)
- lines = template % locals()
- lines = lines.split('\n')
+ lines.extend((template % locals()).split('\n'))
state_machine.insert_input(
lines, state_machine.input_lines.source(0))
Modified: trunk/matplotlib/lib/matplotlib/axes.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/axes.py 2008-06-26 17:47:04 UTC (rev 5680)
+++ trunk/matplotlib/lib/matplotlib/axes.py 2008-06-26 18:05:17 UTC (rev 5681)
@@ -2879,6 +2879,9 @@
*linestyle*:
[ 'solid' | 'dashed' | 'dashdot' | 'dotted' ]
+ **Example:**
+
+ .. plot:: ../mpl_examples/pylab_examples/hline_demo.py
"""
if kwargs.get('fmt') is not None:
raise DeprecationWarning(
@@ -3362,6 +3365,13 @@
See the respective :meth:`~matplotlib.axes.Axes.plot` or
:meth:`~matplotlib.axes.Axes.vlines` functions for
documentation on valid kwargs.
+
+ **Example:**
+
+ :func:`~matplotlib.pyplot.xcorr` above, and
+ :func:`~matplotlib.pyplot.acorr` below.
+
+ .. plot:: ../mpl_examples/pylab_examples/xcorr_demo.py
"""
return self.xcorr(x, x, **kwargs)
acorr.__doc__ = cbook.dedent(acorr.__doc__) % martist.kwdocd
@@ -3410,6 +3420,13 @@
*maxlags* is a positive integer detailing the number of lags to show.
The default value of *None* will return all ``(2*len(x)-1)`` lags.
+
+ **Example:**
+
+ :func:`~matplotlib.pyplot.xcorr` above, and
+ :func:`~matplotlib.pyplot.acorr` below.
+
+ .. plot:: ../mpl_examples/pylab_examples/xcorr_demo.py
"""
Nx = len(x)
@@ -3706,6 +3723,12 @@
Other optional kwargs:
%(Rectangle)s
+
+ **Example:**
+
+ A stacked bar chart.
+
+ .. plot:: ../mpl_examples/pylab_examples/bar_stacked.py
"""
if not self._hold: self.cla()
@@ -3998,6 +4021,10 @@
or a sequence of arguments for the various bars, ie::
facecolors = ('black', 'red', 'green')
+
+ **Example:**
+
+ .. plot:: ../mpl_examples/pylab_examples/broken_barh.py
"""
col = mcoll.BrokenBarHCollection(xranges, yrange, **kwargs)
self.add_collection(col, autolim=True)
@@ -5013,6 +5040,10 @@
:meth:`~matplotlib.collection.PolyCollection.get_array` on
this :class:`~matplotlib.collections.PolyCollection` to get
the counts in each hexagon.
+
+ **Example:**
+
+ .. plot:: ../mpl_examples/pylab_examples/hexbin_demo.py
"""
if not self._hold: self.cla()
@@ -5166,6 +5197,10 @@
Optional kwargs control the arrow properties:
%(FancyArrow)s
+
+ **Example:**
+
+ .. plot:: ../mpl_examples/pylab_examples/arrow_demo.py
"""
a = mpatches.FancyArrow(x, y, dx, dy, **kwargs)
self.add_artist(a)
@@ -5225,6 +5260,10 @@
kwargs control the Polygon properties:
%(Polygon)s
+
+ **Example:**
+
+ .. plot:: ../mpl_examples/pylab_examples/fill_demo.py
"""
if not self._hold: self.cla()
@@ -5334,6 +5373,10 @@
Additional kwargs are :class:`~matplotlib.artist.Artist` properties:
%(Artist)s
+
+ **Example:**
+
+ .. plot:: ../mpl_examples/pylab_examples/image_demo.py
"""
if not self._hold: self.cla()
@@ -6081,42 +6124,6 @@
%(Rectangle)s
- Here is an example which generates a histogram of normally
- distributed random numbers and plot the analytic PDF over it::
-
- import numpy as np
- import matplotlib.pyplot as plt
- import matplotlib.mlab as mlab
-
- mu, sigma = 100, 15
- x = mu + sigma * np.random.randn(10000)
-
- fig = plt.figure()
- ax = fig.add_subplot(111)
-
- # the histogram of the data
- n, bins, patches = ax.hist(x, 50, normed=1, facecolor='green', alpha=0.75)
-
- # hist uses np.histogram under the hood to create 'n' and 'bins'.
- # np.histogram returns the bin edges, so there will be 50 probability
- # density values in n, 51 bin edges in bins and 50 patches. To get
- # everything lined up, we'll compute the bin centers
- bincenters = 0.5*(bins[1:]+bins[:-1])
-
- # add a 'best fit' line for the normal PDF
- y = mlab.normpdf( bincenters, mu, sigma)
- l = ax.plot(bincenters, y, 'r--', linewidth=1)
-
- ax.set_xlabel('Smarts')
- ax.set_ylabel('Probability')
- ax.set_title(r'$\mathrm{Histogram\ of\ IQ:}\ \mu=100,\ \sigma=15$')
- ax.set_xlim(40, 160)
- ax.set_ylim(0, 0.03)
- ax.grid(True)
-
- #fig.savefig('histogram_demo',dpi=72)
- plt.show()
-
You can use labels for your histogram, and only the first
:class:`~matplotlib.patches.Rectangle` gets the label (the
others get the magic string '_nolegend_'. This will make the
@@ -6126,6 +6133,9 @@
ax.hist(12+3*np.random.randn(1000), label='women', alpha=0.5)
ax.legend()
+ **Example:**
+
+ .. plot:: ../mpl_examples/pylab_examples/histogram_demo.py
"""
if not self._hold: self.cla()
@@ -6413,6 +6423,10 @@
kwargs control the Line2D properties:
%(Line2D)s
+
+ **Example:**
+
+ .. plot:: ../mpl_examples/pylab_examples/csd_demo.py
"""
if not self._hold: self.cla()
pxy, freqs = mlab.csd(x, y, NFFT, Fs, detrend, window, noverlap)
@@ -6466,6 +6480,10 @@
properties of the coherence plot:
%(Line2D)s
+
+ **Example:**
+
+ .. plot:: ../mpl_examples/pylab_examples/cohere_demo.py
"""
if not self._hold: self.cla()
cxy, freqs = mlab.cohere(x, y, NFFT, Fs, detrend, window, noverlap)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2008-06-26 20:15:52
|
Revision: 5683
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5683&view=rev
Author: jdh2358
Date: 2008-06-26 13:15:45 -0700 (Thu, 26 Jun 2008)
Log Message:
-----------
cleaned some more examples
Modified Paths:
--------------
trunk/matplotlib/examples/pylab_examples/cohere_demo.py
trunk/matplotlib/examples/pylab_examples/csd_demo.py
trunk/matplotlib/examples/pylab_examples/fill_demo.py
trunk/matplotlib/examples/pylab_examples/hexbin_demo.py
trunk/matplotlib/examples/pylab_examples/histogram_demo.py
trunk/matplotlib/examples/pylab_examples/image_demo.py
Added Paths:
-----------
trunk/matplotlib/lib/mpl_examples
Modified: trunk/matplotlib/examples/pylab_examples/cohere_demo.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/cohere_demo.py 2008-06-26 19:08:48 UTC (rev 5682)
+++ trunk/matplotlib/examples/pylab_examples/cohere_demo.py 2008-06-26 20:15:45 UTC (rev 5683)
@@ -2,36 +2,35 @@
"""
Compute the coherence of two signals
"""
-import numpy as n
+import numpy as np
+import matplotlib.pyplot as plt
-from pylab import figure, show
+# make a little extra space between the subplots
+plt.subplots_adjust(wspace=0.5)
dt = 0.01
-t = n.arange(0, 30, dt)
-Nt = len(t)
-nse1 = n.random.randn(Nt) # white noise 1
-nse2 = n.random.randn(Nt) # white noise 2
-r = n.exp(-t/0.05)
+t = np.arange(0, 30, dt)
+nse1 = np.random.randn(len(t)) # white noise 1
+nse2 = np.random.randn(len(t)) # white noise 2
+r = np.exp(-t/0.05)
-cnse1 = n.convolve(nse1, r)*dt # colored noise 1
-cnse1 = cnse1[:Nt]
-cnse2 = n.convolve(nse2, r)*dt # colored noise 2
-cnse2 = cnse2[:Nt]
+cnse1 = np.convolve(nse1, r, mode='same')*dt # colored noise 1
+cnse2 = np.convolve(nse2, r, mode='same')*dt # colored noise 2
# two signals with a coherent part and a random part
-s1 = 0.01*n.sin(2*n.pi*10*t) + cnse1
-s2 = 0.01*n.sin(2*n.pi*10*t) + cnse2
+s1 = 0.01*np.sin(2*np.pi*10*t) + cnse1
+s2 = 0.01*np.sin(2*np.pi*10*t) + cnse2
-fig = figure()
-ax = fig.add_subplot(211)
-ax.plot(t, s1, 'b-', t, s2, 'g-')
-ax.set_xlim(0,5)
-ax.set_xlabel('time')
-ax.set_ylabel('s1 and s2')
+plt.subplot(211)
+plt.plot(t, s1, 'b-', t, s2, 'g-')
+plt.xlim(0,5)
+plt.xlabel('time')
+plt.ylabel('s1 and s2')
+plt.grid(True)
-ax = fig.add_subplot(212)
-cxy, f = ax.cohere(s1, s2, 256, 1./dt)
+plt.subplot(212)
+cxy, f = plt.cohere(s1, s2, 256, 1./dt)
+plt.ylabel('coherence')
+plt.show()
-show()
-
Modified: trunk/matplotlib/examples/pylab_examples/csd_demo.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/csd_demo.py 2008-06-26 19:08:48 UTC (rev 5682)
+++ trunk/matplotlib/examples/pylab_examples/csd_demo.py 2008-06-26 20:15:45 UTC (rev 5683)
@@ -2,32 +2,35 @@
"""
Compute the cross spectral density of two signals
"""
-from __future__ import division
-from pylab import *
+import numpy as np
+import matplotlib.pyplot as plt
+# make a little extra space between the subplots
+plt.subplots_adjust(wspace=0.5)
+
dt = 0.01
-t = arange(0, 30, dt)
-nse1 = randn(len(t)) # white noise 1
-nse2 = randn(len(t)) # white noise 2
-r = exp(divide(-t,0.05))
+t = np.arange(0, 30, dt)
+nse1 = np.random.randn(len(t)) # white noise 1
+nse2 = np.random.randn(len(t)) # white noise 2
+r = np.exp(-t/0.05)
-cnse1 = convolve(nse1, r, mode=2)*dt # colored noise 1
-cnse1 = cnse1[:len(t)]
-cnse2 = convolve(nse2, r, mode=2)*dt # colored noise 2
-cnse2 = cnse2[:len(t)]
+cnse1 = np.convolve(nse1, r, mode='same')*dt # colored noise 1
+cnse2 = np.convolve(nse2, r, mode='same')*dt # colored noise 2
# two signals with a coherent part and a random part
-s1 = 0.01*sin(2*pi*10*t) + cnse1
-s2 = 0.01*sin(2*pi*10*t) + cnse2
+s1 = 0.01*np.sin(2*np.pi*10*t) + cnse1
+s2 = 0.01*np.sin(2*np.pi*10*t) + cnse2
-subplot(211)
-plot(t, s1, 'b-', t, s2, 'g-')
-xlim(0,5)
-xlabel('time')
-ylabel('s1 and s2')
+plt.subplot(211)
+plt.plot(t, s1, 'b-', t, s2, 'g-')
+plt.xlim(0,5)
+plt.xlabel('time')
+plt.ylabel('s1 and s2')
+plt.grid(True)
-subplot(212)
-cxy, f = csd(s1, s2, 256, 1/dt)
-show()
+plt.subplot(212)
+cxy, f = plt.csd(s1, s2, 256, 1./dt)
+plt.ylabel('CSD (db)')
+plt.show()
Modified: trunk/matplotlib/examples/pylab_examples/fill_demo.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/fill_demo.py 2008-06-26 19:08:48 UTC (rev 5682)
+++ trunk/matplotlib/examples/pylab_examples/fill_demo.py 2008-06-26 20:15:45 UTC (rev 5683)
@@ -1,8 +1,10 @@
#!/usr/bin/env python
-from pylab import *
-t = arange(0.0, 1.01, 0.01)
-s = sin(2*2*pi*t)
+import numpy as np
+import matplotlib.pyplot as plt
-fill(t, s*exp(-5*t), 'r')
-grid(True)
-show()
+t = np.arange(0.0, 1.01, 0.01)
+s = np.sin(2*2*np.pi*t)
+
+plt.fill(t, s*np.exp(-5*t), 'r')
+plt.grid(True)
+plt.show()
Modified: trunk/matplotlib/examples/pylab_examples/hexbin_demo.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/hexbin_demo.py 2008-06-26 19:08:48 UTC (rev 5682)
+++ trunk/matplotlib/examples/pylab_examples/hexbin_demo.py 2008-06-26 20:15:45 UTC (rev 5683)
@@ -1,13 +1,12 @@
-'''
+"""
hexbin is an axes method or pyplot function that is essentially
a pcolor of a 2-D histogram with hexagonal cells. It can be
much more informative than a scatter plot; in the first subplot
below, try substituting 'scatter' for 'hexbin'.
-'''
+"""
-from matplotlib.pyplot import *
import numpy as np
-
+import matplotlib.pyplot as plt
n = 100000
x = np.random.standard_normal(n)
y = 2.0 + 3.0 * x + 4.0 * np.random.standard_normal(n)
@@ -16,19 +15,20 @@
ymin = y.min()
ymax = y.max()
-subplot(121)
-hexbin(x,y)
-axis([xmin, xmax, ymin, ymax])
-title("Hexagon binning")
-cb = colorbar()
+plt.subplots_adjust(hspace=0.5)
+plt.subplot(121)
+plt.hexbin(x,y)
+plt.axis([xmin, xmax, ymin, ymax])
+plt.title("Hexagon binning")
+cb = plt.colorbar()
cb.set_label('counts')
-subplot(122)
-hexbin(x,y,bins='log')
-axis([xmin, xmax, ymin, ymax])
-title("With a log color scale")
-cb = colorbar()
+plt.subplot(122)
+plt.hexbin(x,y,bins='log')
+plt.axis([xmin, xmax, ymin, ymax])
+plt.title("With a log color scale")
+cb = plt.colorbar()
cb.set_label('log10(N)')
-show()
+plt.show()
Modified: trunk/matplotlib/examples/pylab_examples/histogram_demo.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/histogram_demo.py 2008-06-26 19:08:48 UTC (rev 5682)
+++ trunk/matplotlib/examples/pylab_examples/histogram_demo.py 2008-06-26 20:15:45 UTC (rev 5683)
@@ -1,23 +1,22 @@
#!/usr/bin/env python
-import pylab as P
+import numpy as np
+import matplotlib.mlab as mlab
+import matplotlib.pyplot as plt
mu, sigma = 100, 15
-x = mu + sigma*P.randn(10000)
+x = mu + sigma*np.random.randn(10000)
# the histogram of the data
-n, bins, patches = P.hist(x, 50, normed=1)
-P.setp(patches, 'facecolor', 'g', 'alpha', 0.75)
+n, bins, patches = plt.hist(x, 50, normed=1, facecolor='green', alpha=0.75)
# add a 'best fit' line
-y = P.normpdf( bins, mu, sigma)
-l = P.plot(bins, y, 'r--')
-P.setp(l, 'linewidth', 1)
+y = mlab.normpdf( bins, mu, sigma)
+l = plt.plot(bins, y, 'r--', linewidth=1)
-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)
+plt.xlabel('Smarts')
+plt.ylabel('Probability')
+plt.title(r'$\mathrm{Histogram\ of\ IQ:}\ \mu=100,\ \sigma=15$')
+plt.axis([40, 160, 0, 0.03])
+plt.grid(True)
-#P.savefig('histogram_demo',dpi=72)
-P.show()
+plt.show()
Modified: trunk/matplotlib/examples/pylab_examples/image_demo.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/image_demo.py 2008-06-26 19:08:48 UTC (rev 5682)
+++ trunk/matplotlib/examples/pylab_examples/image_demo.py 2008-06-26 20:15:45 UTC (rev 5683)
@@ -1,16 +1,18 @@
#!/usr/bin/env python
-from pylab import *
+import numpy as np
+import matplotlib.cm as cm
+import matplotlib.mlab as mlab
+import matplotlib.pyplot as plt
delta = 0.025
-x = y = arange(-3.0, 3.0, delta)
-X, Y = meshgrid(x, y)
-Z1 = bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)
-Z2 = bivariate_normal(X, Y, 1.5, 0.5, 1, 1)
+x = y = np.arange(-3.0, 3.0, delta)
+X, Y = np.meshgrid(x, y)
+Z1 = mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)
+Z2 = mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1)
Z = Z2-Z1 # difference of Gaussians
-im = imshow(Z, interpolation='bilinear', cmap=cm.gray,
- origin='lower', extent=[-3,3,-3,3])
+im = plt.imshow(Z, interpolation='bilinear', cmap=cm.gray,
+ origin='lower', extent=[-3,3,-3,3])
-savefig('image_demo')
-show()
+plt.show()
Added: trunk/matplotlib/lib/mpl_examples
===================================================================
--- trunk/matplotlib/lib/mpl_examples (rev 0)
+++ trunk/matplotlib/lib/mpl_examples 2008-06-26 20:15:45 UTC (rev 5683)
@@ -0,0 +1 @@
+link ../examples
\ No newline at end of file
Property changes on: trunk/matplotlib/lib/mpl_examples
___________________________________________________________________
Name: svn:special
+ *
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2008-06-27 12:51:51
|
Revision: 5685
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5685&view=rev
Author: mdboom
Date: 2008-06-27 05:51:50 -0700 (Fri, 27 Jun 2008)
Log Message:
-----------
Merged revisions 5678-5684 via svnmerge from
https://matplotlib.svn.sf.net/svnroot/matplotlib/branches/v0_91_maint
........
r5684 | mdboom | 2008-06-27 08:49:34 -0400 (Fri, 27 Jun 2008) | 2 lines
Fix mathtext parsing bug.
........
Modified Paths:
--------------
trunk/matplotlib/CHANGELOG
trunk/matplotlib/lib/matplotlib/mathtext.py
Property Changed:
----------------
trunk/matplotlib/
Property changes on: trunk/matplotlib
___________________________________________________________________
Name: svnmerge-integrated
- /branches/v0_91_maint:1-5677
+ /branches/v0_91_maint:1-5684
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2008-06-27 12:49:34 UTC (rev 5684)
+++ trunk/matplotlib/CHANGELOG 2008-06-27 12:51:50 UTC (rev 5685)
@@ -1,3 +1,5 @@
+2008-06-26 Fix mathtext bug for expressions like $x_{\leftarrow}$ - MGD
+
2008-06-26 Fix direction of horizontal/vertical hatches - MGD
2008-06-25 Figure.figurePatch renamed Figure.patch, Axes.axesPatch
Modified: trunk/matplotlib/lib/matplotlib/mathtext.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/mathtext.py 2008-06-27 12:49:34 UTC (rev 5684)
+++ trunk/matplotlib/lib/matplotlib/mathtext.py 2008-06-27 12:51:50 UTC (rev 5685)
@@ -2088,7 +2088,7 @@
start_group
+ ZeroOrMore(
autoDelim
- | simple)
+ ^ simple)
- end_group
).setParseAction(self.group).setName("group")
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|