SourceForge logo
SourceForge logo
Menu

matplotlib-checkins — Commit notification. DO NOT POST to this list, just subscribe to it.

You can subscribe to this list here.

2007 Jan
Feb
Mar
Apr
May
Jun
Jul
(115)
Aug
(120)
Sep
(137)
Oct
(170)
Nov
(461)
Dec
(263)
2008 Jan
(120)
Feb
(74)
Mar
(35)
Apr
(74)
May
(245)
Jun
(356)
Jul
(240)
Aug
(115)
Sep
(78)
Oct
(225)
Nov
(98)
Dec
(271)
2009 Jan
(132)
Feb
(84)
Mar
(74)
Apr
(56)
May
(90)
Jun
(79)
Jul
(83)
Aug
(296)
Sep
(214)
Oct
(76)
Nov
(82)
Dec
(66)
2010 Jan
(46)
Feb
(58)
Mar
(51)
Apr
(77)
May
(58)
Jun
(126)
Jul
(128)
Aug
(64)
Sep
(50)
Oct
(44)
Nov
(48)
Dec
(54)
2011 Jan
(68)
Feb
(52)
Mar
Apr
May
Jun
Jul
Aug
Sep
Oct
Nov
Dec
(1)
2018 Jan
Feb
Mar
Apr
May
(1)
Jun
Jul
Aug
Sep
Oct
Nov
Dec
S M T W T F S


1
(3)
2
(2)
3
(5)
4
(1)
5
6
7
(6)
8
(3)
9
(7)
10
(6)
11
(14)
12
(6)
13
(10)
14
(6)
15
16
17
(15)
18
(6)
19
(1)
20
(4)
21
(8)
22
(9)
23
(12)
24
(35)
25
(21)
26
(14)
27
(11)
28
(9)
29
(11)
30
(6)
31
(9)


Showing results of 240

<< < 1 .. 8 9 10 (Page 10 of 10)
From: <md...@us...> - 2008年07月07日 17:48:50
Revision: 5716
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5716&view=rev
Author: mdboom
Date: 2008年07月07日 10:48:36 -0700 (2008年7月07日)
Log Message:
-----------
Fix custom scales in pcolormesh (thanks, Matthew Turk)
Modified Paths:
--------------
 trunk/matplotlib/examples/pylab_examples/quadmesh_demo.py
 trunk/matplotlib/lib/matplotlib/collections.py
Modified: trunk/matplotlib/examples/pylab_examples/quadmesh_demo.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/quadmesh_demo.py	2008年07月07日 17:37:33 UTC (rev 5715)
+++ trunk/matplotlib/examples/pylab_examples/quadmesh_demo.py	2008年07月07日 17:48:36 UTC (rev 5716)
@@ -29,6 +29,8 @@
 ax = fig.add_subplot(121)
 ax.set_axis_bgcolor("#bdb76b")
 ax.pcolormesh(Qx,Qz,Z)
+ax.set_xscale('log')
+ax.set_yscale('log')
 ax.set_title('Without masked values')
 
 ax = fig.add_subplot(122)
Modified: trunk/matplotlib/lib/matplotlib/collections.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/collections.py	2008年07月07日 17:37:33 UTC (rev 5715)
+++ trunk/matplotlib/lib/matplotlib/collections.py	2008年07月07日 17:48:36 UTC (rev 5716)
@@ -512,14 +512,24 @@
 if clippath_trans is not None:
 clippath_trans = clippath_trans.frozen()
 
- assert transform.is_affine
+ if not transform.is_affine:
+ coordinates = self._coordinates.reshape(
+ (self._coordinates.shape[0] *
+ self._coordinates.shape[1],
+ 2))
+ coordinates = transform.transform(coordinates)
+ coordinates = coordinates.reshape(self._coordinates.shape)
+ transform = transforms.IdentityTransform()
+ else:
+ coordinates = self._coordinates
+
 if not transOffset.is_affine:
 offsets = transOffset.transform_non_affine(offsets)
 transOffset = transOffset.get_affine()
 
 renderer.draw_quad_mesh(
 transform.frozen(), self.clipbox, clippath, clippath_trans,
- self._meshWidth, self._meshHeight, self._coordinates,
+ self._meshWidth, self._meshHeight, coordinates,
 offsets, transOffset, self._facecolors, self._antialiased,
 self._showedges)
 renderer.close_group(self.__class__.__name__)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <sa...@us...> - 2008年07月07日 17:37:58
Revision: 5715
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5715&view=rev
Author: sameerd
Date: 2008年07月07日 10:37:33 -0700 (2008年7月07日)
Log Message:
-----------
bug fixes - edgecases
Modified Paths:
--------------
 trunk/matplotlib/examples/misc/rec_join_demo.py
 trunk/matplotlib/lib/matplotlib/mlab.py
Modified: trunk/matplotlib/examples/misc/rec_join_demo.py
===================================================================
--- trunk/matplotlib/examples/misc/rec_join_demo.py	2008年07月07日 12:12:52 UTC (rev 5714)
+++ trunk/matplotlib/examples/misc/rec_join_demo.py	2008年07月07日 17:37:33 UTC (rev 5715)
@@ -2,7 +2,7 @@
 import matplotlib.mlab as mlab
 
 
-r = mlab.csv2rec('data/aapl.csv')
+r = mlab.csv2rec('../data/aapl.csv')
 r.sort()
 r1 = r[-10:]
 
Modified: trunk/matplotlib/lib/matplotlib/mlab.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/mlab.py	2008年07月07日 12:12:52 UTC (rev 5714)
+++ trunk/matplotlib/lib/matplotlib/mlab.py	2008年07月07日 17:37:33 UTC (rev 5715)
@@ -2081,10 +2081,12 @@
 def rec_join(key, r1, r2, jointype='inner', defaults=None):
 """
 join record arrays r1 and r2 on key; key is a tuple of field
- names. if r1 and r2 have equal values on all the keys in the key
+ names. If r1 and r2 have equal values on all the keys in the key
 tuple, then their fields will be merged into a new record array
- containing the intersection of the fields of r1 and r2
+ containing the intersection of the fields of r1 and r2. 
 
+ r1 (also r2) must not have any duplicate keys. 
+
 The jointype keyword can be 'inner', 'outer', 'leftouter'.
 To do a rightouter join just reverse r1 and r2.
 
@@ -2123,9 +2125,6 @@
 right_ind = np.array([r2d[k] for k in right_keys])
 right_len = len(right_ind)
 
- r2 = rec_drop_fields(r2, r1.dtype.names)
-
-
 def key_desc(name):
 'if name is a string key, use the larger size of r1 or r2 before merging'
 dt1 = r1.dtype[name]
@@ -2158,21 +2157,17 @@
 
 for field in r1.dtype.names:
 newrec[field][:common_len] = r1[field][r1ind]
- if jointype == "outer" or jointype == "leftouter":
+ if (jointype == "outer" or jointype == "leftouter") and left_len:
 newrec[field][common_len:(common_len+left_len)] = r1[field][left_ind]
 
 for field in r2.dtype.names:
- newrec[field][:common_len] = r2[field][r2ind]
- if jointype == "outer":
- newrec[field][-right_len:] = r2[field][right_ind[right_ind.argsort()]]
+ if field not in key:
+ newrec[field][:common_len] = r2[field][r2ind]
+ if jointype == "outer" and right_len:
+ newrec[field][-right_len:] = r2[field][right_ind]
 
- # sort newrec using the same order as r1
- sort_indices = r1ind.copy()
- if jointype == "outer" or jointype == "leftouter":
- sort_indices = np.append(sort_indices, left_ind)
- newrec[:(common_len+left_len)] = newrec[sort_indices.argsort()]
+ newrec.sort(order=key)
 
-
 return newrec.view(np.recarray)
 
 
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <js...@us...> - 2008年07月07日 12:12:57
Revision: 5714
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5714&view=rev
Author: jswhit
Date: 2008年07月07日 05:12:52 -0700 (2008年7月07日)
Log Message:
-----------
added mollweide example
Modified Paths:
--------------
 trunk/toolkits/basemap/doc/users/mapsetup.rst
Added Paths:
-----------
 trunk/toolkits/basemap/doc/users/figures/moll.png
 trunk/toolkits/basemap/doc/users/figures/moll.py
 trunk/toolkits/basemap/doc/users/moll.rst
Added: trunk/toolkits/basemap/doc/users/figures/moll.png
===================================================================
(Binary files differ)
Property changes on: trunk/toolkits/basemap/doc/users/figures/moll.png
___________________________________________________________________
Name: svn:mime-type
 + application/octet-stream
Added: trunk/toolkits/basemap/doc/users/figures/moll.py
===================================================================
--- trunk/toolkits/basemap/doc/users/figures/moll.py	 (rev 0)
+++ trunk/toolkits/basemap/doc/users/figures/moll.py	2008年07月07日 12:12:52 UTC (rev 5714)
@@ -0,0 +1,14 @@
+from mpl_toolkits.basemap import Basemap
+import numpy as np
+import matplotlib.pyplot as plt
+# lon_0 is central longitude of projection.
+# resolution = 'c' means use crude resolution coastlines.
+m = Basemap(projection='moll',lon_0=0,resolution='c')
+m.drawcoastlines()
+m.fillcontinents(color='coral',lake_color='aqua')
+# draw parallels and meridians.
+m.drawparallels(np.arange(-90.,120.,30.))
+m.drawmeridians(np.arange(0.,420.,60.))
+m.drawmapboundary(fill_color='aqua') 
+plt.title("Mollweide Projection")
+plt.savefig('moll.png')
Modified: trunk/toolkits/basemap/doc/users/mapsetup.rst
===================================================================
--- trunk/toolkits/basemap/doc/users/mapsetup.rst	2008年07月07日 00:17:57 UTC (rev 5713)
+++ trunk/toolkits/basemap/doc/users/mapsetup.rst	2008年07月07日 12:12:52 UTC (rev 5714)
@@ -31,3 +31,4 @@
 azeqd.rst
 gnomon.rst
 ortho.rst
+ moll.rst
Added: trunk/toolkits/basemap/doc/users/moll.rst
===================================================================
--- trunk/toolkits/basemap/doc/users/moll.rst	 (rev 0)
+++ trunk/toolkits/basemap/doc/users/moll.rst	2008年07月07日 12:12:52 UTC (rev 5714)
@@ -0,0 +1,10 @@
+.. _moll:
+
+Mollweide Projection
+====================
+
+The mollweide projection is a global, elliptical, equal-area projection. 
+
+.. literalinclude:: figures/moll.py
+
+.. image:: figures/moll.png
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <fer...@us...> - 2008年07月07日 00:18:00
Revision: 5713
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5713&view=rev
Author: fer_perez
Date: 2008年07月06日 17:17:57 -0700 (2008年7月06日)
Log Message:
-----------
Add agenda for 2008 SciPy tutorial, plus misc. updates to scripts.
Modified Paths:
--------------
 trunk/py4science/examples/fft_imdenoise.py
 trunk/py4science/examples/glass_dots1.py
 trunk/py4science/examples/lotka_volterra.py
 trunk/py4science/examples/numpy_wrap/f2py/example3/Makefile
 trunk/py4science/examples/skel/fft_imdenoise_skel.py
 trunk/py4science/examples/skel/fortran_wrap/Makefile
 trunk/py4science/examples/skel/fortran_wrap/fib3.f
 trunk/py4science/examples/skel/glass_dots1_skel.py
 trunk/py4science/examples/stock_demo.py
 trunk/py4science/examples/stock_records.py
 trunk/py4science/examples/weave_blitz.py
 trunk/py4science/examples/weave_examples_simple.py
Added Paths:
-----------
 trunk/py4science/classes/0808_scipy_agenda.txt
Added: trunk/py4science/classes/0808_scipy_agenda.txt
===================================================================
--- trunk/py4science/classes/0808_scipy_agenda.txt	 (rev 0)
+++ trunk/py4science/classes/0808_scipy_agenda.txt	2008年07月07日 00:17:57 UTC (rev 5713)
@@ -0,0 +1,94 @@
+=========================================================
+ Introduction to Scientific Computing in Python - Agenda
+=========================================================
+
+.. contents::
+..
+ 1 Introduction and resources
+ 2 Day 1
+..
+
+Introduction and resources
+==========================
+
+While the tutorial will begin with very basic concepts, we will assume that
+attendees have given the free online `Python tutorial`_ a very decent read, and
+will have installed on their systems all the prerequisite tools.
+
+.. _`Python tutorial`: http://docs.python.org/tut
+
+In addition, the following are good sources of information for the tools we'll
+be using (all are linked from the main `SciPy documentation`_ page):
+
+ * The `STSci tutorial`_ on interactive data analysis.
+ * The tentative `NumPy tutorial`_.
+ * The list of NumPy `functions with examples`_.
+ * The SciPy community cookbook_.
+
+.. _`SciPy documentation`: http://www.scipy.org/Documentation
+.. _`STSci tutorial`: http://www.scipy.org/wikis/topical_software/Tutorial
+.. _`NumPy tutorial`: http://www.scipy.org/Tentative_NumPy_Tutorial
+.. _`functions with examples`: http://www.scipy.org/Numpy_Example_List_With_Doc
+.. _`cookbook`: http://www.scipy.org/Cookbook
+
+
+Initials indicate who presents what:
+
+ * MD: Michael Droetboom
+ * PG: Perry Greenfield
+ * FP: Fernando Perez
+
+
+Day 1
+=====
+
+* Python for scientific computing: A high-level overview of the topic of Python
+ in a scientific context ( simple 30 minute talk).
+
+* Workflow, guided by a simple examples and students typing along. Will show
+ basics of everyday workflow as we cover the core concepts.
+
+ * Basic scalar types: strings and numbers (int, float, complex). Exercise:
+ Walli's infinte product formula for Pi.
+
+ * Basic collections: lists and dicts (mention tuples and sets). Exercise:
+ word frequency counting.
+
+ * Quick review of control flow: if, for, range, while, break, continue.
+
+ * Defining functions. Arguments and docstrings.
+
+ * Reusing your code: every script is a module, '__main__' (notes on module
+ loading and reloading)
+
+ * Exceptions: a core concept in Python, you really can't use the language
+ without them.
+
+ * Debugging your programs:
+ * Ye olde print statement.
+ * %debug in ipython.
+ * %run -d in ipython.
+ * winpdb - a free, cross-platform GUI debugger.
+
+ * Testing your code: reproducible research from the start. Making a habit
+ out of having auto-validated code.
+
+* Introduction to NumPy arrays.
+ * Memory model.
+ * The dtype concept.
+ * Creating arrays.
+ * Basic operations: arithmetic and slicing.
+ * Indexing modes. Views vs. copies.
+ * Functions that operate on arrays: the builtins and making your own.
+ * Saving and reloading arrays on disk.
+
+ Exercises: Trapezoid rule integration. Image denoising using FFTs.
+
+* Working with data
+ * Reading files.
+ * Simple text parsing.
+ * CSV files.
+ * Matplotlib's data loader.
+
+
+* Python packages and modules, the very basics: __init__.py and $PYTHONPATH.
Modified: trunk/py4science/examples/fft_imdenoise.py
===================================================================
--- trunk/py4science/examples/fft_imdenoise.py	2008年07月04日 19:20:43 UTC (rev 5712)
+++ trunk/py4science/examples/fft_imdenoise.py	2008年07月07日 00:17:57 UTC (rev 5713)
@@ -3,14 +3,13 @@
 
 import sys
 
-import numpy as N
-import pylab as P
-import scipy as S
+import numpy as np
+from matplotlib import pyplot as plt
 
 def mag_phase(F):
 """Return magnitude and phase components of spectrum F."""
 
- return (N.absolute(F), N.angle(F))
+ return (np.absolute(F), np.angle(F))
 
 def plot_spectrum(F, amplify=1000):
 """Normalise, amplify and plot an amplitude spectrum."""
@@ -19,19 +18,19 @@
 M[M > 1] = 1
 
 print M.shape, M.dtype
- P.imshow(M, P.cm.Blues)
+ plt.imshow(M, plt.cm.Blues)
 
 try:
 # Read in original image, convert to floating point for further
 # manipulation; imread returns a MxNx4 RGBA image. Since the
 # image is grayscale, just extrac the 1st channel
- im = P.imread('data/moonlanding.png').astype(float)[:,:,0]
+ im = plt.imread('data/moonlanding.png').astype(float)[:,:,0]
 except:
 print "Could not open image."
 sys.exit(-1)
 
 # Compute the 2d FFT of the input image
-F = N.fft.fft2(im)
+F = np.fft.fft2(im)
 
 # Now, make a copy of the original spectrum and truncate coefficients.
 keep_fraction = 0.1
@@ -52,27 +51,27 @@
 
 # Reconstruct the denoised image from the filtered spectrum, keep only the real
 # part for display
-im_new = N.fft.ifft2(ff).real
+im_new = np.fft.ifft2(ff).real
 
 # Show the results
-P.figure()
+plt.figure()
 
-P.subplot(221)
-P.title('Original image')
-P.imshow(im, P.cm.gray)
+plt.subplot(221)
+plt.title('Original image')
+plt.imshow(im, plt.cm.gray)
 
-P.subplot(222)
-P.title('Fourier transform')
+plt.subplot(222)
+plt.title('Fourier transform')
 plot_spectrum(F)
 
-P.subplot(224)
-P.title('Filtered Spectrum')
+plt.subplot(224)
+plt.title('Filtered Spectrum')
 plot_spectrum(ff)
 
-P.subplot(223)
-P.title('Reconstructed Image')
-P.imshow(im_new, P.cm.gray)
+plt.subplot(223)
+plt.title('Reconstructed Image')
+plt.imshow(im_new, plt.cm.gray)
 
-P.savefig('fft_imdenoise.png', dpi=150)
-P.savefig('fft_imdenoise.eps')
-P.show()
+plt.savefig('fft_imdenoise.png', dpi=150)
+plt.savefig('fft_imdenoise.eps')
+plt.show()
Modified: trunk/py4science/examples/glass_dots1.py
===================================================================
--- trunk/py4science/examples/glass_dots1.py	2008年07月04日 19:20:43 UTC (rev 5712)
+++ trunk/py4science/examples/glass_dots1.py	2008年07月07日 00:17:57 UTC (rev 5713)
@@ -5,17 +5,12 @@
 
 See L. Glass. 'Moire effect from random dots' Nature 223, 578580 (1969).
 """
+import cmath
 from numpy import cos, sin, pi, matrix
 import numpy as npy
 import numpy.linalg as linalg
 from pylab import figure, show
 
-def csqrt(x):
- """
- sqrt func that handles returns sqrt(x)j for x<0
- """
- if x<0: return complex(0, npy.sqrt(abs(x)))
- else: return npy.sqrt(x)
 
 def myeig(M):
 """
@@ -34,12 +29,13 @@
 tau = a+d # the trace
 delta = a*d-b*c # the determinant
 
- lambda1 = (tau + csqrt(tau**2 - 4*delta))/2.
- lambda2 = (tau - csqrt(tau**2 - 4*delta))/2.
+ lambda1 = (tau + cmath.sqrt(tau**2 - 4*delta))/2.
+ lambda2 = (tau - cmath.sqrt(tau**2 - 4*delta))/2.
 return lambda1, lambda2
 
 # 2000 random x,y points in the interval[-0.5 ... 0.5]
-X1 = matrix(npy.random.rand(2,2000))-0.5
+X1 = matrix(npy.random.rand(2,2000)
+ )-0.5
 
 name = 'saddle'
 sx, sy, angle = 1.05, 0.95, 0.
Modified: trunk/py4science/examples/lotka_volterra.py
===================================================================
--- trunk/py4science/examples/lotka_volterra.py	2008年07月04日 19:20:43 UTC (rev 5712)
+++ trunk/py4science/examples/lotka_volterra.py	2008年07月07日 00:17:57 UTC (rev 5713)
@@ -46,7 +46,7 @@
 
 
 p.figure()
-p.plot(r, f)
+p.plot(r, f, color='red')
 p.xlabel('rabbits')
 p.ylabel('foxes')
 p.title('phase plane')
@@ -65,8 +65,8 @@
 dR = dr(R, F)
 dF = df(R, F)
 
-p.contour(R, F, dR, levels=[0], linewidths=3, colors='black')
-p.contour(R, F, dF, levels=[0], linewidths=3, colors='black')
+p.contour(R, F, dR, levels=[0], linewidths=3, colors='blue')
+p.contour(R, F, dF, levels=[0], linewidths=3, colors='green')
 p.ylabel('foxes')
 p.title('trajectory, direction field and null clines')
 
Modified: trunk/py4science/examples/numpy_wrap/f2py/example3/Makefile
===================================================================
--- trunk/py4science/examples/numpy_wrap/f2py/example3/Makefile	2008年07月04日 19:20:43 UTC (rev 5712)
+++ trunk/py4science/examples/numpy_wrap/f2py/example3/Makefile	2008年07月07日 00:17:57 UTC (rev 5713)
@@ -1,10 +1,7 @@
 
-#F2PY=f2py
+F2PY=f2py
 
-F2PY=f2py2.4
 
-#F2PY=/usr/local/txpython/local/Frameworks/Python.framework/Versions/2.5/bin/f2py
-
 clean:
 	rm -f fib3.pyf example.so
 
Modified: trunk/py4science/examples/skel/fft_imdenoise_skel.py
===================================================================
--- trunk/py4science/examples/skel/fft_imdenoise_skel.py	2008年07月04日 19:20:43 UTC (rev 5712)
+++ trunk/py4science/examples/skel/fft_imdenoise_skel.py	2008年07月07日 00:17:57 UTC (rev 5713)
@@ -36,7 +36,7 @@
 # channel from the MxNx4 RGBA matrix to represent the grayscale
 # intensities
 
-F = # Compute the 2d FFT of the input image. Look for a 2-d FFT in N.dft
+F = # Compute the 2d FFT of the input image. Look for a 2-d FFT in N.fft.
 
 # Define the fraction of coefficients (in each direction) we keep
 keep_fraction = 0.1
Modified: trunk/py4science/examples/skel/fortran_wrap/Makefile
===================================================================
--- trunk/py4science/examples/skel/fortran_wrap/Makefile	2008年07月04日 19:20:43 UTC (rev 5712)
+++ trunk/py4science/examples/skel/fortran_wrap/Makefile	2008年07月07日 00:17:57 UTC (rev 5713)
@@ -1,10 +1,7 @@
 
-#F2PY=f2py
+F2PY=f2py
 
-F2PY=f2py2.4
 
-#F2PY=/usr/local/txpython/local/Frameworks/Python.framework/Versions/2.5/bin/f2py
-
 clean:
 	rm -f fib3.pyf example.so
 
Modified: trunk/py4science/examples/skel/fortran_wrap/fib3.f
===================================================================
--- trunk/py4science/examples/skel/fortran_wrap/fib3.f	2008年07月04日 19:20:43 UTC (rev 5712)
+++ trunk/py4science/examples/skel/fortran_wrap/fib3.f	2008年07月07日 00:17:57 UTC (rev 5713)
@@ -19,7 +19,7 @@
 ENDDO
 END
 
- SUBROUTINE CUMSUM(X, Y, N)
+C SUBROUTINE CUMSUM(X, Y, N)
 C
 C COMPUTE THE CUMULATIVE SUM OF X
 C
Modified: trunk/py4science/examples/skel/glass_dots1_skel.py
===================================================================
--- trunk/py4science/examples/skel/glass_dots1_skel.py	2008年07月04日 19:20:43 UTC (rev 5712)
+++ trunk/py4science/examples/skel/glass_dots1_skel.py	2008年07月07日 00:17:57 UTC (rev 5713)
@@ -5,15 +5,12 @@
 
 See L. Glass. 'Moire effect from random dots' Nature 223, 578580 (1969).
 """
+import cmath # provides complex math functions
 from numpy import cos, sin, pi, matrix
 import numpy as npy
 import numpy.linalg as linalg
 from pylab import figure, show
 
-def csqrt(x):
- 'sqrt func that handles returns sqrt(x)j for x<0'
- XXX
- 
 def myeig(M):
 """
 compute eigen values and eigenvectors analytically
Modified: trunk/py4science/examples/stock_demo.py
===================================================================
--- trunk/py4science/examples/stock_demo.py	2008年07月04日 19:20:43 UTC (rev 5712)
+++ trunk/py4science/examples/stock_demo.py	2008年07月07日 00:17:57 UTC (rev 5713)
@@ -38,5 +38,4 @@
 # <demo> stop
 # Now, make a slightly modified version of the file with cleaner formatting.
 # We'll use this later...
-mlab.rec2csv(r,'dap/myserver/data/sample.csv',
- formatd={'date':mlab.FormatString()})
+#
Modified: trunk/py4science/examples/stock_records.py
===================================================================
--- trunk/py4science/examples/stock_records.py	2008年07月04日 19:20:43 UTC (rev 5712)
+++ trunk/py4science/examples/stock_records.py	2008年07月07日 00:17:57 UTC (rev 5713)
@@ -40,7 +40,7 @@
 tickers = 'SPY', 'QQQQ', 'INTC', 'MSFT', 'YHOO', 'GOOG', 'GE', 'WMT', 'AAPL'
 
 # we want to compute returns since 2003, so define the start date
-startdate = datetime.datetime(2003,1,1)
+startdate = datetime.date(2003,1,1)
 
 # we'll store a list of each return and ticker for analysis later
 data = [] # a list of (return, ticker) for each stock 
Modified: trunk/py4science/examples/weave_blitz.py
===================================================================
--- trunk/py4science/examples/weave_blitz.py	2008年07月04日 19:20:43 UTC (rev 5712)
+++ trunk/py4science/examples/weave_blitz.py	2008年07月07日 00:17:57 UTC (rev 5713)
@@ -5,12 +5,11 @@
 
 import sys, time
 
-import numpy
-from numpy import zeros
+import numpy as np
 from scipy import weave
-from pylab import subplot, plot, show, legend, xlabel, ylabel, title
+from pylab import figure,subplot, plot, show, legend, xlabel, ylabel, title
 
-rand = numpy.random.rand
+rand = np.random.rand
 
 Nadds = 12
 Nevals = 10
@@ -45,7 +44,7 @@
 # can disrupt timings
 if useWeave:
 # only weave needs to predefine result array
- result= zeros(shape,dtype=float)
+ result= np.empty(shape,dtype=float)
 times[0] = now()
 for j in evalRng:
 blitz(s)
@@ -67,9 +66,10 @@
 nn, tn = repeat_nadds(Nadds, Nevals, useWeave=False)
 
 # plot weave versus Numeric
+figure()
 ax = subplot(111)
 plot(nw, tw, 'go', nn, tn, 'bs')
-legend( ('Weave', 'Numeric') )
+legend( ('Blitz', 'Numpy') )
 xlabel('num adds')
 ylabel('time (s)')
 title('numpy vs weave; repeated adds, shape: %s' % (shape,))
Modified: trunk/py4science/examples/weave_examples_simple.py
===================================================================
--- trunk/py4science/examples/weave_examples_simple.py	2008年07月04日 19:20:43 UTC (rev 5712)
+++ trunk/py4science/examples/weave_examples_simple.py	2008年07月07日 00:17:57 UTC (rev 5713)
@@ -1,9 +1,8 @@
 #!/usr/bin/env python
 """Some simple examples of weave.inline use"""
 
+import numpy as np
 from scipy.weave import inline,converters
-import numpy as N
-from pylab import rand
 
 #-----------------------------------------------------------------------------
 # Returning a scalar quantity computed from an array.
@@ -37,16 +36,49 @@
 inline(code,['num','mat','nrow','ncol'],
 type_converters = converters.blitz)
 
-def main():
- zz = N.zeros([10,10])
+def prod(m, v):
+ #C++ version
+ nrows, ncolumns = m.shape
+ assert v.ndim==1 and ncolumns==v.shape[0],"Shape mismatch in prod"
+ 
+ res = np.zeros(nrows, float)
+ code = r"""
+ for (int i=0; i<nrows; i++)
+ {
+ for (int j=0; j<ncolumns; j++)
+ {
+ res(i) += m(i,j)*v(j);
+ }
+ }
+ """
+ err = inline(code,['nrows', 'ncolumns', 'res', 'm', 'v'], verbose=2,
+ type_converters=converters.blitz)
+ return res
+
+
+if __name__=='__main__':
+ print 'zz is all zeros'
+ zz = np.zeros([10,10])
 print 'tr(zz)=',trace(zz)
- oo = N.ones([4,4],N.float)
+ print 'oo is all ones'
+ oo = np.ones([4,4],float)
 print 'tr(oo)=',trace(oo)
- aa = rand(128,128)
+ print 'aa is random'
+ aa = np.random.rand(128,128)
 print 'tr(aa)=',trace(aa)
+ print 'tr(aa)=',np.trace(aa),' (via numpy)'
+
+ print
+ print 'Modify oo in place:'
 print 'oo:',oo
 in_place_mult(3,oo)
 print '3*oo:',oo
 
-if __name__=='__main__':
- main()
+ print
+ print 'Simple matrix-vector multiply'
+ nr,nc = 20,10
+ m = np.random.rand(nr,nc)
+ v = np.random.rand(nc)
+ mv = prod(m,v)
+ mvd = np.dot(m,v)
+ print 'Mat*vec error:',np.linalg.norm(mv-mvd)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5712
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5712&view=rev
Author: efiring
Date: 2008年07月04日 12:20:43 -0700 (2008年7月04日)
Log Message:
-----------
fix numpy, ma imports in geo.py
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/projections/geo.py
Modified: trunk/matplotlib/lib/matplotlib/projections/geo.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/projections/geo.py	2008年07月03日 16:08:52 UTC (rev 5711)
+++ trunk/matplotlib/lib/matplotlib/projections/geo.py	2008年07月04日 19:20:43 UTC (rev 5712)
@@ -1,7 +1,7 @@
 import math
 
-import numpy as npy
-from matplotlib.numerix import npyma as ma
+import numpy as np
+import numpy.ma as ma
 
 import matplotlib
 rcParams = matplotlib.rcParams
@@ -27,7 +27,7 @@
 self._round_to = round_to
 
 def __call__(self, x, pos=None):
- degrees = (x / npy.pi) * 180.0
+ degrees = (x / np.pi) * 180.0
 degrees = round(degrees / self._round_to) * self._round_to
 # \u00b0 : degree symbol
 return u"%d\u00b0" % degrees
@@ -47,8 +47,8 @@
 
 self.grid(rcParams['axes.grid'])
 
- Axes.set_xlim(self, -npy.pi, npy.pi)
- Axes.set_ylim(self, -npy.pi / 2.0, npy.pi / 2.0)
+ Axes.set_xlim(self, -np.pi, np.pi)
+ Axes.set_ylim(self, -np.pi / 2.0, np.pi / 2.0)
 
 def _set_lim_and_transforms(self):
 # A (possibly non-linear) projection on the (already scaled) data
@@ -83,7 +83,7 @@
 Affine2D().translate(0.0, -4.0)
 
 # This is the transform for latitude ticks.
- yaxis_stretch = Affine2D().scale(npy.pi * 2.0, 1.0).translate(-npy.pi, 0.0)
+ yaxis_stretch = Affine2D().scale(np.pi * 2.0, 1.0).translate(-np.pi, 0.0)
 yaxis_space = Affine2D().scale(1.0, 1.1)
 self._yaxis_transform = \
 yaxis_stretch + \
@@ -103,8 +103,8 @@
 
 def _get_affine_transform(self):
 transform = self._get_core_transform(1)
- xscale, _ = transform.transform_point((npy.pi, 0))
- _, yscale = transform.transform_point((0, npy.pi / 2.0))
+ xscale, _ = transform.transform_point((np.pi, 0))
+ _, yscale = transform.transform_point((0, np.pi / 2.0))
 return Affine2D() \
 .scale(0.5 / xscale, 0.5 / yscale) \
 .translate(0.5, 0.5)
@@ -137,15 +137,15 @@
 set_xscale = set_yscale
 
 def set_xlim(self, *args, **kwargs):
- Axes.set_xlim(self, -npy.pi, npy.pi)
- Axes.set_ylim(self, -npy.pi / 2.0, npy.pi / 2.0)
+ Axes.set_xlim(self, -np.pi, np.pi)
+ Axes.set_ylim(self, -np.pi / 2.0, np.pi / 2.0)
 
 set_ylim = set_xlim
 
 def format_coord(self, long, lat):
 'return a format string formatting the coordinate'
- long = long * (180.0 / npy.pi)
- lat = lat * (180.0 / npy.pi)
+ long = long * (180.0 / np.pi)
+ lat = lat * (180.0 / np.pi)
 if lat >= 0.0:
 ns = 'N'
 else:
@@ -163,7 +163,7 @@
 number = (360.0 / degrees) + 1
 self.xaxis.set_major_locator(
 FixedLocator(
- npy.linspace(-npy.pi, npy.pi, number, True)[1:-1]))
+ np.linspace(-np.pi, np.pi, number, True)[1:-1]))
 self._logitude_degrees = degrees
 self.xaxis.set_major_formatter(self.ThetaFormatter(degrees))
 
@@ -174,7 +174,7 @@
 number = (180.0 / degrees) + 1
 self.yaxis.set_major_locator(
 FixedLocator(
- npy.linspace(-npy.pi / 2.0, npy.pi / 2.0, number, True)[1:-1]))
+ np.linspace(-np.pi / 2.0, np.pi / 2.0, number, True)[1:-1]))
 self._latitude_degrees = degrees
 self.yaxis.set_major_formatter(self.ThetaFormatter(degrees))
 
@@ -182,7 +182,7 @@
 """
 Set the latitude(s) at which to stop drawing the longitude grids.
 """
- self._longitude_cap = degrees * (npy.pi / 180.0)
+ self._longitude_cap = degrees * (np.pi / 180.0)
 self._xaxis_pretransform \
 .clear() \
 .scale(1.0, self._longitude_cap * 2.0) \
@@ -238,19 +238,19 @@
 
 # Pre-compute some values
 half_long = longitude / 2.0
- cos_latitude = npy.cos(latitude)
+ cos_latitude = np.cos(latitude)
 
- alpha = npy.arccos(cos_latitude * npy.cos(half_long))
+ alpha = np.arccos(cos_latitude * np.cos(half_long))
 # Mask this array, or we'll get divide-by-zero errors
 alpha = ma.masked_where(alpha == 0.0, alpha)
 # We want unnormalized sinc. numpy.sinc gives us normalized
 sinc_alpha = ma.sin(alpha) / alpha
 
- x = (cos_latitude * npy.sin(half_long)) / sinc_alpha
- y = (npy.sin(latitude) / sinc_alpha)
+ x = (cos_latitude * np.sin(half_long)) / sinc_alpha
+ y = (np.sin(latitude) / sinc_alpha)
 x.set_fill_value(0.0)
 y.set_fill_value(0.0)
- return npy.concatenate((x.filled(), y.filled()), 1)
+ return np.concatenate((x.filled(), y.filled()), 1)
 transform.__doc__ = Transform.transform.__doc__
 
 transform_non_affine = transform
@@ -288,7 +288,7 @@
 inverted.__doc__ = Transform.inverted.__doc__
 
 def __init__(self, *args, **kwargs):
- self._longitude_cap = npy.pi / 2.0
+ self._longitude_cap = np.pi / 2.0
 GeoAxes.__init__(self, *args, **kwargs)
 self.set_aspect(0.5, adjustable='box', anchor='C')
 self.cla()
@@ -323,13 +323,13 @@
 
 # Pre-compute some values
 half_long = longitude / 2.0
- cos_latitude = npy.cos(latitude)
- sqrt2 = npy.sqrt(2.0)
+ cos_latitude = np.cos(latitude)
+ sqrt2 = np.sqrt(2.0)
 
- alpha = 1.0 + cos_latitude * npy.cos(half_long)
- x = (2.0 * sqrt2) * (cos_latitude * npy.sin(half_long)) / alpha
- y = (sqrt2 * npy.sin(latitude)) / alpha
- return npy.concatenate((x, y), 1)
+ alpha = 1.0 + cos_latitude * np.cos(half_long)
+ x = (2.0 * sqrt2) * (cos_latitude * np.sin(half_long)) / alpha
+ y = (sqrt2 * np.sin(latitude)) / alpha
+ return np.concatenate((x, y), 1)
 transform.__doc__ = Transform.transform.__doc__
 
 transform_non_affine = transform
@@ -363,10 +363,10 @@
 
 quarter_x = 0.25 * x
 half_y = 0.5 * y
- z = npy.sqrt(1.0 - quarter_x*quarter_x - half_y*half_y)
- longitude = 2 * npy.arctan((z*x) / (2.0 * (2.0*z*z - 1.0)))
- latitude = npy.arcsin(y*z)
- return npy.concatenate((longitude, latitude), 1)
+ z = np.sqrt(1.0 - quarter_x*quarter_x - half_y*half_y)
+ longitude = 2 * np.arctan((z*x) / (2.0 * (2.0*z*z - 1.0)))
+ latitude = np.arcsin(y*z)
+ return np.concatenate((longitude, latitude), 1)
 transform.__doc__ = Transform.transform.__doc__
 
 def inverted(self):
@@ -374,7 +374,7 @@
 inverted.__doc__ = Transform.inverted.__doc__
 
 def __init__(self, *args, **kwargs):
- self._longitude_cap = npy.pi / 2.0
+ self._longitude_cap = np.pi / 2.0
 GeoAxes.__init__(self, *args, **kwargs)
 self.set_aspect(0.5, adjustable='box', anchor='C')
 self.cla()
@@ -407,11 +407,11 @@
 longitude = ll[:, 0:1]
 latitude = ll[:, 1:2]
 
- aux = 2.0 * npy.arcsin((2.0 * latitude) / npy.pi)
- x = (2.0 * npy.sqrt(2.0) * longitude * npy.cos(aux)) / npy.pi
- y = (npy.sqrt(2.0) * npy.sin(aux))
+ aux = 2.0 * np.arcsin((2.0 * latitude) / np.pi)
+ x = (2.0 * np.sqrt(2.0) * longitude * np.cos(aux)) / np.pi
+ y = (np.sqrt(2.0) * np.sin(aux))
 
- return npy.concatenate((x, y), 1)
+ return np.concatenate((x, y), 1)
 transform.__doc__ = Transform.transform.__doc__
 
 transform_non_affine = transform
@@ -449,7 +449,7 @@
 inverted.__doc__ = Transform.inverted.__doc__
 
 def __init__(self, *args, **kwargs):
- self._longitude_cap = npy.pi / 2.0
+ self._longitude_cap = np.pi / 2.0
 GeoAxes.__init__(self, *args, **kwargs)
 self.set_aspect(0.5, adjustable='box', anchor='C')
 self.cla()
@@ -485,22 +485,22 @@
 latitude = ll[:, 1:2]
 clong = self._center_longitude
 clat = self._center_latitude
- cos_lat = npy.cos(latitude)
- sin_lat = npy.sin(latitude)
+ cos_lat = np.cos(latitude)
+ sin_lat = np.sin(latitude)
 diff_long = longitude - clong
- cos_diff_long = npy.cos(diff_long)
+ cos_diff_long = np.cos(diff_long)
 
 inner_k = (1.0 +
- npy.sin(clat)*sin_lat +
- npy.cos(clat)*cos_lat*cos_diff_long)
+ np.sin(clat)*sin_lat +
+ np.cos(clat)*cos_lat*cos_diff_long)
 # Prevent divide-by-zero problems
- inner_k = npy.where(inner_k == 0.0, 1e-15, inner_k)
- k = npy.sqrt(2.0 / inner_k)
- x = k*cos_lat*npy.sin(diff_long)
- y = k*(npy.cos(clat)*sin_lat -
- npy.sin(clat)*cos_lat*cos_diff_long)
+ inner_k = np.where(inner_k == 0.0, 1e-15, inner_k)
+ k = np.sqrt(2.0 / inner_k)
+ x = k*cos_lat*np.sin(diff_long)
+ y = k*(np.cos(clat)*sin_lat -
+ np.sin(clat)*cos_lat*cos_diff_long)
 
- return npy.concatenate((x, y), 1)
+ return np.concatenate((x, y), 1)
 transform.__doc__ = Transform.transform.__doc__
 
 transform_non_affine = transform
@@ -538,18 +538,18 @@
 y = xy[:, 1:2]
 clong = self._center_longitude
 clat = self._center_latitude
- p = npy.sqrt(x*x + y*y)
- p = npy.where(p == 0.0, 1e-9, p)
- c = 2.0 * npy.arcsin(0.5 * p)
- sin_c = npy.sin(c)
- cos_c = npy.cos(c)
+ p = np.sqrt(x*x + y*y)
+ p = np.where(p == 0.0, 1e-9, p)
+ c = 2.0 * np.arcsin(0.5 * p)
+ sin_c = np.sin(c)
+ cos_c = np.cos(c)
 
- lat = npy.arcsin(cos_c*npy.sin(clat) +
- ((y*sin_c*npy.cos(clat)) / p))
- long = clong + npy.arctan(
- (x*sin_c) / (p*npy.cos(clat)*cos_c - y*npy.sin(clat)*sin_c))
+ lat = np.arcsin(cos_c*np.sin(clat) +
+ ((y*sin_c*np.cos(clat)) / p))
+ long = clong + np.arctan(
+ (x*sin_c) / (p*np.cos(clat)*cos_c - y*np.sin(clat)*sin_c))
 
- return npy.concatenate((long, lat), 1)
+ return np.concatenate((long, lat), 1)
 transform.__doc__ = Transform.transform.__doc__
 
 def inverted(self):
@@ -560,7 +560,7 @@
 inverted.__doc__ = Transform.inverted.__doc__
 
 def __init__(self, *args, **kwargs):
- self._longitude_cap = npy.pi / 2.0
+ self._longitude_cap = np.pi / 2.0
 self._center_longitude = kwargs.pop("center_longitude", 0.0)
 self._center_latitude = kwargs.pop("center_latitude", 0.0)
 GeoAxes.__init__(self, *args, **kwargs)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <md...@us...> - 2008年07月03日 16:09:29
Revision: 5711
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5711&view=rev
Author: mdboom
Date: 2008年07月03日 09:08:52 -0700 (2008年7月03日)
Log Message:
-----------
O(n) implementation of Grouper.__iter__
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/cbook.py
Modified: trunk/matplotlib/lib/matplotlib/cbook.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/cbook.py	2008年07月03日 14:30:41 UTC (rev 5710)
+++ trunk/matplotlib/lib/matplotlib/cbook.py	2008年07月03日 16:08:52 UTC (rev 5711)
@@ -1030,7 +1030,7 @@
 >>> g.join('a', 'b')
 >>> g.join('b', 'c')
 >>> g.join('d', 'e')
- >>> list(g.get())
+ >>> list(g)
 [['a', 'b', 'c'], ['d', 'e']]
 >>> g.joined('a', 'b')
 True
@@ -1079,14 +1079,25 @@
 
 def __iter__(self):
 """
- Returns an iterator yielding each of the disjoint sets as a list.
+ Iterate over each of the disjoint sets as a list.
+
+ The iterator is invalid if interleaved with calls to join().
 """
- seen = set()
- for elem, group in self._mapping.iteritems():
- if elem not in seen:
+ class Token: pass
+ token = Token()
+
+ # Mark each group as we come across if by appending a token,
+ # and don't yield it twice
+ for group in self._mapping.itervalues():
+ if not group[-1] is token:
 yield group
- seen.update(group)
+ group.append(token)
 
+ # Cleanup the tokens
+ for group in self._mapping.itervalues():
+ if group[-1] is token:
+ del group[-1]
+
 def get_siblings(self, a):
 """
 Returns all of the items joined with *a*, including itself.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5710
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5710&view=rev
Author: jdh2358
Date: 2008年07月03日 07:30:41 -0700 (2008年7月03日)
Log Message:
-----------
added findobj
Modified Paths:
--------------
 trunk/matplotlib/examples/pylab_examples/findobj_demo.py
Modified: trunk/matplotlib/examples/pylab_examples/findobj_demo.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/findobj_demo.py	2008年07月03日 14:30:13 UTC (rev 5709)
+++ trunk/matplotlib/examples/pylab_examples/findobj_demo.py	2008年07月03日 14:30:41 UTC (rev 5710)
@@ -1,3 +1,6 @@
+"""
+Recursuvely find all objects that match some criteria
+"""
 import numpy as np
 import matplotlib.pyplot as plt
 import matplotlib.text as text
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <jd...@us...> - 2008年07月03日 14:30:16
Revision: 5709
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5709&view=rev
Author: jdh2358
Date: 2008年07月03日 07:30:13 -0700 (2008年7月03日)
Log Message:
-----------
added findobj
Modified Paths:
--------------
 trunk/matplotlib/CHANGELOG
 trunk/matplotlib/lib/matplotlib/artist.py
 trunk/matplotlib/lib/matplotlib/cbook.py
 trunk/matplotlib/lib/matplotlib/legend.py
 trunk/matplotlib/lib/matplotlib/pylab.py
 trunk/matplotlib/lib/matplotlib/pyplot.py
Added Paths:
-----------
 trunk/matplotlib/examples/pylab_examples/findobj_demo.py
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG	2008年07月03日 13:38:52 UTC (rev 5708)
+++ trunk/matplotlib/CHANGELOG	2008年07月03日 14:30:13 UTC (rev 5709)
@@ -1,3 +1,6 @@
+2007年07月03日 Implemented findobj method for artist and pyplot - see
+ examples/pylab_examples/findobj_demo.py - JDH
+
 2008年06月30日 Another attempt to fix TextWithDash - DSD
 
 2008年06月30日 Removed Qt4 NavigationToolbar2.destroy -- it appears to 
Added: trunk/matplotlib/examples/pylab_examples/findobj_demo.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/findobj_demo.py	 (rev 0)
+++ trunk/matplotlib/examples/pylab_examples/findobj_demo.py	2008年07月03日 14:30:13 UTC (rev 5709)
@@ -0,0 +1,34 @@
+import numpy as np
+import matplotlib.pyplot as plt
+import matplotlib.text as text
+
+a = np.arange(0,3,.02)
+b = np.arange(0,3,.02)
+c = np.exp(a)
+d = c[::-1]
+
+fig = plt.figure()
+ax = fig.add_subplot(111)
+plt.plot(a,c,'k--',a,d,'k:',a,c+d,'k')
+plt.legend(('Model length', 'Data length', 'Total message length'),
+ 'upper center', shadow=True)
+plt.ylim([-1,20])
+plt.grid(False)
+plt.xlabel('Model complexity --->')
+plt.ylabel('Message length --->')
+plt.title('Minimum Message Length')
+
+# match on arbitrary function
+def myfunc(x):
+ return hasattr(x, 'set_color')
+
+for o in fig.findobj(myfunc):
+ o.set_color('blue')
+
+# match on class instances
+for o in fig.findobj(text.Text):
+ o.set_fontstyle('italic')
+
+
+
+plt.show()
Modified: trunk/matplotlib/lib/matplotlib/artist.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/artist.py	2008年07月03日 13:38:52 UTC (rev 5708)
+++ trunk/matplotlib/lib/matplotlib/artist.py	2008年07月03日 14:30:13 UTC (rev 5709)
@@ -508,7 +508,47 @@
 ret.extend( [func(v)] )
 return ret
 
+ def findobj(self, match=None):
+ """
+ recursively find all :class:matplotlib.artist.Artist instances
+ contained in self
 
+ *match* can be
+
+ - None: return all objects contained in artist (including artist)
+
+ - function with signature ``boolean = match(artist)`` used to filter matches
+
+ - class instance: eg Line2D. Only return artists of class type
+ """
+
+ if match is None: # always return True
+ def matchfunc(x): return True
+ elif cbook.issubclass_safe(match, Artist):
+ def matchfunc(x):
+ return isinstance(x, match)
+ elif callable(match):
+ matchfunc = match
+ else:
+ raise ValueError('match must be None, an matplotlib.artist.Artist subclass, or a callable')
+
+
+ artists = []
+ if hasattr(self, 'get_children'):
+ for c in self.get_children():
+ if matchfunc(c):
+ artists.append(c)
+ artists.extend([thisc for thisc in c.findobj(matchfunc) if matchfunc(thisc)])
+ else:
+ if matchfunc(self):
+ artists.append(self)
+ return artists
+
+
+
+
+
+
 class ArtistInspector:
 """
 A helper class to inspect an :class:`~matplotlib.artist.Artist`
@@ -690,6 +730,48 @@
 return lines
 
 
+
+ def findobj(self, match=None):
+ """
+ recursively find all :class:matplotlib.artist.Artist instances
+ contained in self
+
+ if *match* is not None, it can be
+
+ - function with signature ``boolean = match(artist)``
+
+ - class instance: eg Line2D
+
+ used to filter matches
+ """
+
+ if match is None: # always return True
+ def matchfunc(x): return True
+ elif issubclass(match, Artist):
+ def matchfunc(x):
+ return isinstance(x, match)
+ elif callable(match):
+ matchfunc = func
+ else:
+ raise ValueError('match must be None, an matplotlib.artist.Artist subclass, or a callable')
+
+
+ artists = []
+ if hasattr(self, 'get_children'):
+ for c in self.get_children():
+ if matchfunc(c):
+ artists.append(c)
+ artists.extend([thisc for thisc in c.findobj(matchfunc) if matchfunc(thisc)])
+ else:
+ if matchfunc(self):
+ artists.append(self)
+ return artists
+
+
+
+
+
+
 def getp(o, property=None):
 """
 Return the value of handle property. property is an optional string
Modified: trunk/matplotlib/lib/matplotlib/cbook.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/cbook.py	2008年07月03日 13:38:52 UTC (rev 5708)
+++ trunk/matplotlib/lib/matplotlib/cbook.py	2008年07月03日 14:30:13 UTC (rev 5709)
@@ -886,7 +886,14 @@
 raise ValueError(_safezip_msg % (Nx, i+1, len(arg)))
 return zip(*args)
 
+def issubclass_safe(x, klass):
+ 'return issubclass(x, klass) and return False on a TypeError'
 
+ try:
+ return issubclass(x, klass)
+ except TypeError:
+ return False
+
 class MemoryMonitor:
 def __init__(self, nmax=20000):
 self._nmax = nmax
Modified: trunk/matplotlib/lib/matplotlib/legend.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/legend.py	2008年07月03日 13:38:52 UTC (rev 5708)
+++ trunk/matplotlib/lib/matplotlib/legend.py	2008年07月03日 14:30:13 UTC (rev 5709)
@@ -363,6 +363,12 @@
 'b is a boolean. Set draw frame to b'
 self._drawFrame = b
 
+ def get_children(self):
+ children = []
+ children.extend(self.legendHandles)
+ children.extend(self.texts)
+ return children
+
 def get_frame(self):
 'return the Rectangle instance used to frame the legend'
 return self.legendPatch
Modified: trunk/matplotlib/lib/matplotlib/pylab.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/pylab.py	2008年07月03日 13:38:52 UTC (rev 5708)
+++ trunk/matplotlib/lib/matplotlib/pylab.py	2008年07月03日 14:30:13 UTC (rev 5709)
@@ -38,6 +38,7 @@
 figtext - add text in figure coords
 figure - create or change active figure
 fill - make filled polygons
+ findobj - recursively find all objects matching some criteria
 gca - return the current axes
 gcf - return the current figure
 gci - get the current image, or None
Modified: trunk/matplotlib/lib/matplotlib/pyplot.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/pyplot.py	2008年07月03日 13:38:52 UTC (rev 5708)
+++ trunk/matplotlib/lib/matplotlib/pyplot.py	2008年07月03日 14:30:13 UTC (rev 5709)
@@ -38,6 +38,29 @@
 from matplotlib.backends import pylab_setup
 new_figure_manager, draw_if_interactive, show = pylab_setup()
 
+
+
+def findobj(o=None, match=None):
+ """
+ recursively find all :class:matplotlib.artist.Artist instances
+ contained in artist instance *p*. if *o* is None, use
+ current figure
+
+ *match* can be
+
+ - None: return all objects contained in artist (including artist)
+
+ - function with signature ``boolean = match(artist)`` used to filter matches
+
+ - class instance: eg Line2D. Only return artists of class type
+
+ """
+
+ if o is None:
+ o = gcf()
+ return o.findobj(match)
+
+
 def switch_backend(newbackend):
 """
 Switch the default backend to newbackend. This feature is
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <jd...@us...> - 2008年07月03日 13:38:59
Revision: 5708
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5708&view=rev
Author: jdh2358
Date: 2008年07月03日 06:38:52 -0700 (2008年7月03日)
Log Message:
-----------
fixed text picking
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/text.py
Added Paths:
-----------
 trunk/matplotlib/examples/api/line_with_text.py
Added: trunk/matplotlib/examples/api/line_with_text.py
===================================================================
--- trunk/matplotlib/examples/api/line_with_text.py	 (rev 0)
+++ trunk/matplotlib/examples/api/line_with_text.py	2008年07月03日 13:38:52 UTC (rev 5708)
@@ -0,0 +1,65 @@
+"""
+Show how to override basic methods so an artist can contain another
+artist. In this case, the line contains a Text instance to label it.
+"""
+import numpy as np
+import matplotlib.pyplot as plt
+import matplotlib.lines as lines
+import matplotlib.transforms as mtransforms
+import matplotlib.text as mtext
+
+
+class MyLine(lines.Line2D):
+
+ def __init__(self, *args, **kwargs):
+ # we'll update the position when the line data is set
+ self.text = mtext.Text(0, 0, '')
+ lines.Line2D.__init__(self, *args, **kwargs)
+
+ # we can't access the label attr until *after* the line is
+ # inited
+ self.text.set_text(self.get_label())
+
+ def set_figure(self, figure):
+ self.text.set_figure(figure)
+ lines.Line2D.set_figure(self, figure)
+
+ def set_axes(self, axes):
+ self.text.set_axes(axes)
+ lines.Line2D.set_axes(self, axes)
+
+ def set_transform(self, transform):
+ # 2 pixel offset
+ texttrans = transform + mtransforms.Affine2D().translate(2, 2)
+ self.text.set_transform(texttrans)
+ lines.Line2D.set_transform(self, transform)
+
+
+ def set_data(self, x, y):
+ if len(x):
+ self.text.set_position((x[-1], y[-1]))
+
+ lines.Line2D.set_data(self, x, y)
+
+ def draw(self, renderer):
+ # draw my label at the end of the line with 2 pixel offset
+ lines.Line2D.draw(self, renderer)
+ self.text.draw(renderer)
+
+
+
+
+
+fig = plt.figure()
+ax = fig.add_subplot(111)
+x, y = np.random.rand(2, 20)
+line = MyLine(x, y, mfc='red', ms=12, label='line label')
+#line.text.set_text('line label')
+line.text.set_color('red')
+line.text.set_fontsize(16)
+
+
+ax.add_line(line)
+
+
+plt.show()
Modified: trunk/matplotlib/lib/matplotlib/text.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/text.py	2008年07月03日 13:21:54 UTC (rev 5707)
+++ trunk/matplotlib/lib/matplotlib/text.py	2008年07月03日 13:38:52 UTC (rev 5708)
@@ -135,17 +135,15 @@
 """
 if callable(self._contains): return self._contains(self,mouseevent)
 
- try:
- l,b,w,h = self.get_window_extent().get_bounds()
- except:
- # TODO: why does this error occur
- #print str(self),"error looking at get_window_extent"
- return False,{}
+
+ l,b,w,h = self.get_window_extent().bounds
+
 r = l+w
 t = b+h
 xyverts = (l,b), (l, t), (r, t), (r, b)
 x, y = mouseevent.x, mouseevent.y
 inside = nxutils.pnpoly(x, y, xyverts)
+
 return inside,{}
 
 def _get_xy_display(self):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <jd...@us...> - 2008年07月03日 13:22:14
Revision: 5707
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5707&view=rev
Author: jdh2358
Date: 2008年07月03日 06:21:54 -0700 (2008年7月03日)
Log Message:
-----------
axes was not calling artist set_axes method in set artist props
Modified Paths:
--------------
 trunk/matplotlib/examples/widgets/menu.py
 trunk/matplotlib/lib/matplotlib/axes.py
 trunk/matplotlib/lib/matplotlib/pyplot.py
 trunk/matplotlib/src/_backend_agg.cpp
 trunk/matplotlib/src/_backend_agg.h
 trunk/matplotlib/unit/memleak_hawaii3.py
Modified: trunk/matplotlib/examples/widgets/menu.py
===================================================================
--- trunk/matplotlib/examples/widgets/menu.py	2008年07月02日 15:36:38 UTC (rev 5706)
+++ trunk/matplotlib/examples/widgets/menu.py	2008年07月03日 13:21:54 UTC (rev 5707)
@@ -1,45 +1,76 @@
 import numpy as np
 import matplotlib
+import matplotlib.colors as colors
 import matplotlib.patches as patches
 import matplotlib.mathtext as mathtext
 import matplotlib.pyplot as plt
 import matplotlib.artist as artist
 import matplotlib.image as image
 
-matplotlib.rc('image', origin='upper')
 
+class ItemProperties:
+ def __init__(self, fontsize=14, labelcolor='black', bgcolor='yellow', alpha=1.0):
+ self.fontsize = fontsize
+ self.labelcolor = labelcolor
+ self.bgcolor = bgcolor
+ self.alpha = alpha
+
+ self.labelcolor_rgb = colors.colorConverter.to_rgb(labelcolor)
+ self.bgcolor_rgb = colors.colorConverter.to_rgb(bgcolor)
+
 class MenuItem(artist.Artist):
 parser = mathtext.MathTextParser("Bitmap")
 padx = 5
 pady =5
- def __init__(self, fig, labelstr):
+ def __init__(self, fig, labelstr, props=None, hoverprops=None, on_select=None):
 artist.Artist.__init__(self)
+
 self.set_figure(fig)
+ self.labelstr = labelstr
 
+ if props is None:
+ props = ItemProperties()
 
- x, self.depth = self.parser.to_rgba(
- labelstr, color='black', fontsize=14, dpi=100)
- xHover, depth = self.parser.to_rgba(
- labelstr, color='white', fontsize=14, dpi=100)
+ if hoverprops is None:
+ hoverprops = ItemProperties()
 
+ self.props = props
+ self.hoverprops = hoverprops
 
+
+ self.on_select = on_select
+
+ x, self.depth = self.parser.to_mask(
+ labelstr, fontsize=props.fontsize, dpi=fig.dpi)
+
+ if props.fontsize!=hoverprops.fontsize:
+ raise NotImplementedError('support for different font sizes not implemented')
+
+
 self.labelwidth = x.shape[1]
 self.labelheight = x.shape[0]
- print 'h', self.labelheight
- self.label = image.FigureImage(fig)
- self.label.set_array(x.astype(float)/255.)
 
- self.labelHover = image.FigureImage(fig)
- self.labelHover.set_array(xHover.astype(float)/255.)
+ self.labelArray = np.zeros((x.shape[0], x.shape[1], 4))
+ self.labelArray[:,:,-1] = x/255.
 
+ self.label = image.FigureImage(fig, origin='upper')
+ self.label.set_array(self.labelArray)
 
-
 # we'll update these later
- self.rect = patches.Rectangle((0,0), 1,1, facecolor='yellow', alpha=0.2)
- self.rectHover = patches.Rectangle((0,0), 1,1, facecolor='blue', alpha=0.2)
+ self.rect = patches.Rectangle((0,0), 1,1)
 
+ self.set_hover_props(False)
 
+ fig.canvas.mpl_connect('button_release_event', self.check_select)
 
+ def check_select(self, event):
+ over, junk = self.rect.contains(event)
+ if not over:
+ return
+
+ if self.on_select is not None:
+ self.on_select(self)
+
 def set_extent(self, x, y, w, h):
 print x, y, w, h
 self.rect.set_x(x)
@@ -47,65 +78,64 @@
 self.rect.set_width(w)
 self.rect.set_height(h)
 
- self.rectHover.set_x(x)
- self.rectHover.set_y(y)
- self.rectHover.set_width(w)
- self.rectHover.set_height(h)
-
 self.label.ox = x+self.padx
 self.label.oy = y-self.depth+self.pady/2.
 
 self.rect._update_patch_transform()
- self.rectHover._update_patch_transform()
- self.labelHover.ox = x+self.padx
- self.labelHover.oy = y-self.depth+self.pady/2.
 self.hover = False
 
- self.activeRect = self.rect
- self.activeLabel = self.label
-
 def draw(self, renderer):
- self.activeRect.draw(renderer)
- self.activeLabel.draw(renderer)
+ self.rect.draw(renderer)
+ self.label.draw(renderer)
 
+ def set_hover_props(self, b):
+ if b:
+ props = self.hoverprops
+ else:
+ props = self.props
+
+ r, g, b = props.labelcolor_rgb
+ self.labelArray[:,:,0] = r
+ self.labelArray[:,:,1] = g
+ self.labelArray[:,:,2] = b
+ self.label.set_array(self.labelArray)
+ self.rect.set(facecolor=props.bgcolor, alpha=props.alpha)
+
 def set_hover(self, event):
 'check the hover status of event and return true if status is changed'
 b,junk = self.rect.contains(event)
- if b:
- self.activeRect = self.rectHover
- self.activeLabel = self.labelHover
- else:
- self.activeRect = self.rect
- self.activeLabel = self.label
 
- h = self.hover
+ changed = (b != self.hover)
+
+ if changed:
+ self.set_hover_props(b)
+
+
 self.hover = b
- return b!=h
+ return changed
 
 class Menu:
 
- def __init__(self, fig, labels):
+ def __init__(self, fig, menuitems):
 self.figure = fig
 fig.suppressComposite = True
- menuitems = []
- self.numitems = len(labels)
- for label in labels:
- menuitems.append(MenuItem(fig, label))
 
 self.menuitems = menuitems
+ self.numitems = len(menuitems)
 
-
 maxw = max([item.labelwidth for item in menuitems])
 maxh = max([item.labelheight for item in menuitems])
 
 
 totalh = self.numitems*maxh + (self.numitems+1)*2*MenuItem.pady
 
+
 x0 = 100
 y0 = 400
 
 width = maxw + 2*MenuItem.padx
 height = maxh+MenuItem.pady
+
 for item in menuitems:
 left = x0
 bottom = y0-maxh-MenuItem.pady
@@ -122,17 +152,27 @@
 def on_move(self, event):
 draw = False
 for item in self.menuitems:
- b = item.set_hover(event)
- draw = b
+ draw = item.set_hover(event)
+ if draw:
+ self.figure.canvas.draw()
+ break
 
- if draw:
- print 'draw'
- self.figure.canvas.draw()
 
-
 fig = plt.figure()
-menu = Menu(fig, ('open', 'close', 'save', 'save as', 'quit'))
+fig.subplots_adjust(left=0.3)
+props = ItemProperties(labelcolor='black', bgcolor='yellow',
+ fontsize=15, alpha=0.2)
+hoverprops = ItemProperties(labelcolor='white', bgcolor='blue',
+ fontsize=15, alpha=0.2)
 
+menuitems = []
+for label in ('open', 'close', 'save', 'save as', 'quit'):
+ def on_select(item):
+ print 'you selected', item.labelstr
+ item = MenuItem(fig, label, props=props, hoverprops=hoverprops, on_select=on_select)
+ menuitems.append(item)
+
+menu = Menu(fig, menuitems)
 plt.show()
 
 
Modified: trunk/matplotlib/lib/matplotlib/axes.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/axes.py	2008年07月02日 15:36:38 UTC (rev 5706)
+++ trunk/matplotlib/lib/matplotlib/axes.py	2008年07月03日 13:21:54 UTC (rev 5707)
@@ -813,8 +813,9 @@
 a.set_figure(self.figure)
 if not a.is_transform_set():
 a.set_transform(self.transData)
- a.axes = self
 
+ a.set_axes(self)
+
 def _gen_axes_patch(self):
 """
 Returns the patch used to draw the background of the axes. It
Modified: trunk/matplotlib/lib/matplotlib/pyplot.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/pyplot.py	2008年07月02日 15:36:38 UTC (rev 5706)
+++ trunk/matplotlib/lib/matplotlib/pyplot.py	2008年07月03日 13:21:54 UTC (rev 5707)
@@ -202,6 +202,14 @@
 frameon=frameon,
 FigureClass=FigureClass,
 **kwargs)
+
+ # make this figure current on button press event
+ def make_active(event):
+ _pylab_helpers.Gcf.set_active(figManager)
+
+ cid = figManager.canvas.mpl_connect('button_press_event', make_active)
+ figManager._cidgcf = cid
+
 _pylab_helpers.Gcf.set_active(figManager)
 figManager.canvas.figure.number = num
 
@@ -252,17 +260,21 @@
 if len(args)==0:
 figManager = _pylab_helpers.Gcf.get_active()
 if figManager is None: return
- else: _pylab_helpers.Gcf.destroy(figManager.num)
+ else:
+ figManager.canvas.mpl_disconnect(figManager._cidgcf)
+ _pylab_helpers.Gcf.destroy(figManager.num)
 elif len(args)==1:
 arg = args[0]
 if arg=='all':
 for manager in _pylab_helpers.Gcf.get_all_fig_managers():
+ manager.canvas.mpl_disconnect(manager._cidgcf)
 _pylab_helpers.Gcf.destroy(manager.num)
 elif isinstance(arg, int):
 _pylab_helpers.Gcf.destroy(arg)
 elif isinstance(arg, Figure):
 for manager in _pylab_helpers.Gcf.get_all_fig_managers():
 if manager.canvas.figure==arg:
+ manager.canvas.mpl_disconnect(manager._cidgcf)
 _pylab_helpers.Gcf.destroy(manager.num)
 else:
 raise TypeError('Unrecognized argument type %s to close'%type(arg))
Modified: trunk/matplotlib/src/_backend_agg.cpp
===================================================================
--- trunk/matplotlib/src/_backend_agg.cpp	2008年07月02日 15:36:38 UTC (rev 5706)
+++ trunk/matplotlib/src/_backend_agg.cpp	2008年07月03日 13:21:54 UTC (rev 5707)
@@ -90,6 +90,20 @@
 return Py::String(PyString_FromStringAndSize((const char*)data, height*stride), true);
 }
 
+Py::Object BufferRegion::set_x(const Py::Tuple &args) {
+ args.verify_length(1);
+ size_t x = Py::Int( args[0] );
+ rect.x1 = x;
+ return Py::Object();
+}
+
+Py::Object BufferRegion::set_y(const Py::Tuple &args) {
+ args.verify_length(1);
+ size_t y = Py::Int( args[0] );
+ rect.y1 = y;
+ return Py::Object();
+}
+
 Py::Object BufferRegion::to_string_argb(const Py::Tuple &args) {
 // owned=true to prevent memory leak
 Py_ssize_t length;
@@ -1608,6 +1622,13 @@
 behaviors().name("BufferRegion");
 behaviors().doc("A wrapper to pass agg buffer objects to and from the python level");
 
+
+ add_varargs_method("set_x", &BufferRegion::set_x,
+		 "set_x(x)");
+
+ add_varargs_method("set_y", &BufferRegion::set_y,
+		 "set_y(y)");
+
 add_varargs_method("to_string", &BufferRegion::to_string,
 		 "to_string()");
 add_varargs_method("to_string_argb", &BufferRegion::to_string_argb,
Modified: trunk/matplotlib/src/_backend_agg.h
===================================================================
--- trunk/matplotlib/src/_backend_agg.h	2008年07月02日 15:36:38 UTC (rev 5706)
+++ trunk/matplotlib/src/_backend_agg.h	2008年07月03日 13:21:54 UTC (rev 5707)
@@ -102,6 +102,10 @@
 
 bool freemem;
 
+ // set the x and y corners of the rectangle
+ Py::Object set_x(const Py::Tuple &args);
+ Py::Object set_y(const Py::Tuple &args);
+
 Py::Object to_string(const Py::Tuple &args);
 Py::Object to_string_argb(const Py::Tuple &args);
 static void init_type(void);
Modified: trunk/matplotlib/unit/memleak_hawaii3.py
===================================================================
--- trunk/matplotlib/unit/memleak_hawaii3.py	2008年07月02日 15:36:38 UTC (rev 5706)
+++ trunk/matplotlib/unit/memleak_hawaii3.py	2008年07月03日 13:21:54 UTC (rev 5707)
@@ -2,15 +2,15 @@
 
 import os, sys, time, gc
 import matplotlib
-matplotlib.use('Agg')
+matplotlib.use('PDF')
 
 from matplotlib.cbook import report_memory
-import matplotlib.numerix as nx
+import numpy as np
 from pylab import figure, show, close
 
 # take a memory snapshot on indStart and compare it with indEnd
 
-rand = nx.mlab.rand
+rand = np.mlab.rand
 
 indStart, indEnd = 200, 401
 for i in range(indEnd):
@@ -19,8 +19,8 @@
 fig.clf()
 
 
- t1 = nx.arange(0.0, 2.0, 0.01)
- y1 = nx.sin(2*nx.pi*t1)
+ t1 = np.arange(0.0, 2.0, 0.01)
+ y1 = np.sin(2*np.pi*t1)
 y2 = rand(len(t1))
 X = rand(50,50)
 
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5706
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5706&view=rev
Author: mdboom
Date: 2008年07月02日 08:36:38 -0700 (2008年7月02日)
Log Message:
-----------
Fix bug using autolegend with LineCollection.
Modified Paths:
--------------
 branches/v0_91_maint/lib/matplotlib/legend.py
Modified: branches/v0_91_maint/lib/matplotlib/legend.py
===================================================================
--- branches/v0_91_maint/lib/matplotlib/legend.py	2008年07月02日 11:08:22 UTC (rev 5705)
+++ branches/v0_91_maint/lib/matplotlib/legend.py	2008年07月02日 15:36:38 UTC (rev 5706)
@@ -375,11 +375,11 @@
 
 for handle in ax.collections:
 if isinstance(handle, LineCollection):
- hlines = handle.get_lines()
+ hlines = handle._segments
 trans = handle.get_transform()
 for line in hlines:
 tline = trans.seq_xy_tups(line)
- aline = [inv(v) for v in tline]
+ aline = [inv(tuple(v)) for v in tline]
 lines.append(aline)
 
 return [vertices, bboxes, lines]
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <jd...@us...> - 2008年07月02日 11:08:51
Revision: 5705
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5705&view=rev
Author: jdh2358
Date: 2008年07月02日 04:08:22 -0700 (2008年7月02日)
Log Message:
-----------
cleaned legend demo example
Modified Paths:
--------------
 trunk/matplotlib/examples/pylab_examples/hexbin_demo.py
 trunk/matplotlib/examples/pylab_examples/legend_demo.py
 trunk/matplotlib/lib/matplotlib/axes.py
Added Paths:
-----------
 trunk/matplotlib/examples/api/legend_demo.py
Added: trunk/matplotlib/examples/api/legend_demo.py
===================================================================
--- trunk/matplotlib/examples/api/legend_demo.py	 (rev 0)
+++ trunk/matplotlib/examples/api/legend_demo.py	2008年07月02日 11:08:22 UTC (rev 5705)
@@ -0,0 +1,41 @@
+import numpy as np
+import matplotlib.pyplot as plt
+
+a = np.arange(0,3,.02)
+b = np.arange(0,3,.02)
+c = np.exp(a)
+d = c[::-1]
+
+fig = plt.figure()
+ax = fig.add_subplot(111)
+ax.plot(a,c,'k--',a,d,'k:',a,c+d,'k')
+leg = ax.legend(('Model length', 'Data length', 'Total message length'),
+ 'upper center', shadow=True)
+ax.set_ylim([-1,20])
+ax.grid(False)
+ax.set_xlabel('Model complexity --->')
+ax.set_ylabel('Message length --->')
+ax.set_title('Minimum Message Length')
+
+ax.set_yticklabels([])
+ax.set_xticklabels([])
+
+# set some legend properties. All the code below is optional. The
+# defaults are usually sensible but if you need more control, this
+# shows you how
+
+# the matplotlib.patches.Rectangle instance surrounding the legend
+frame = leg.get_frame() 
+frame.set_facecolor('0.80') # set the frame face color to light gray
+
+# matplotlib.text.Text instances
+for t in leg.get_texts():
+ t.set_fontsize('small') # the legend text fontsize
+
+# matplotlib.lines.Line2D instances
+for l in leg.get_lines():
+ l.set_linewidth(1.5) # the legend line width
+plt.show()
+
+
+
Modified: trunk/matplotlib/examples/pylab_examples/hexbin_demo.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/hexbin_demo.py	2008年07月01日 12:01:38 UTC (rev 5704)
+++ trunk/matplotlib/examples/pylab_examples/hexbin_demo.py	2008年07月02日 11:08:22 UTC (rev 5705)
@@ -6,7 +6,9 @@
 """
 
 import numpy as np
+import matplotlib.cm as cm
 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)
@@ -17,14 +19,14 @@
 
 plt.subplots_adjust(hspace=0.5)
 plt.subplot(121)
-plt.hexbin(x,y)
+plt.hexbin(x,y, cmap=cm.jet)
 plt.axis([xmin, xmax, ymin, ymax])
 plt.title("Hexagon binning")
 cb = plt.colorbar()
 cb.set_label('counts')
 
 plt.subplot(122)
-plt.hexbin(x,y,bins='log')
+plt.hexbin(x,y,bins='log', cmap=cm.jet)
 plt.axis([xmin, xmax, ymin, ymax])
 plt.title("With a log color scale")
 cb = plt.colorbar()
Modified: trunk/matplotlib/examples/pylab_examples/legend_demo.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/legend_demo.py	2008年07月01日 12:01:38 UTC (rev 5704)
+++ trunk/matplotlib/examples/pylab_examples/legend_demo.py	2008年07月02日 11:08:22 UTC (rev 5705)
@@ -4,32 +4,31 @@
 #See http://matplotlib.sf.net/examples/legend_demo2.py for an example
 #controlling which lines the legend uses and the order
 
+import numpy as np
+import matplotlib.pyplot as plt
 
-from pylab import *
+a = np.arange(0,3,.02)
+b = np.arange(0,3,.02)
+c = np.exp(a)
+d = c[::-1]
 
-a = arange(0,3,.02)
-b = arange(0,3,.02)
-c=exp(a)
-d=c.tolist()
-d.reverse()
-d = array(d)
+ax = plt.subplot(111)
+plt.plot(a,c,'k--',a,d,'k:',a,c+d,'k')
+plt.legend(('Model length', 'Data length', 'Total message length'),
+ 'upper center', shadow=True)
+plt.ylim([-1,20])
+plt.grid(False)
+plt.xlabel('Model complexity --->')
+plt.ylabel('Message length --->')
+plt.title('Minimum Message Length')
 
-ax = subplot(111)
-plot(a,c,'k--',a,d,'k:',a,c+d,'k')
-legend(('Model length', 'Data length', 'Total message length'),
- 'upper center', shadow=True)
-ax.set_ylim([-1,20])
-ax.grid(0)
-xlabel('Model complexity --->')
-ylabel('Message length --->')
-title('Minimum Message Length')
-setp(gca(), 'yticklabels', [])
-setp(gca(), 'xticklabels', [])
+plt.setp(plt.gca(), 'yticklabels', [])
+plt.setp(plt.gca(), 'xticklabels', [])
 
 # set some legend properties. All the code below is optional. The
 # defaults are usually sensible but if you need more control, this
 # shows you how
-leg = gca().get_legend()
+leg = plt.gca().get_legend()
 ltext = leg.get_texts() # all the text.Text instance in the legend
 llines = leg.get_lines() # all the lines.Line2D instance in the legend
 frame = leg.get_frame() # the patch.Rectangle instance surrounding the legend
@@ -37,11 +36,11 @@
 # see text.Text, lines.Line2D, and patches.Rectangle for more info on
 # the settable properties of lines, text, and rectangles
 frame.set_facecolor('0.80') # set the frame face color to light gray
-setp(ltext, fontsize='small') # the legend text fontsize
-setp(llines, linewidth=1.5) # the legend linewidth
+plt.setp(ltext, fontsize='small') # the legend text fontsize
+plt.setp(llines, linewidth=1.5) # the legend linewidth
 #leg.draw_frame(False) # don't draw the legend frame
-#savefig('legend_demo')
-show()
+#plt.savefig('legend_demo')
+plt.show()
 
 
 
Modified: trunk/matplotlib/lib/matplotlib/axes.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/axes.py	2008年07月01日 12:01:38 UTC (rev 5704)
+++ trunk/matplotlib/lib/matplotlib/axes.py	2008年07月02日 11:08:22 UTC (rev 5705)
@@ -3592,7 +3592,7 @@
 
 **Example:**
 
- .. plot:: legend_demo.py
+ .. plot:: ../mpl_examples/api/legend_demo.py
 """
 
 def get_handles():
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5704
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5704&view=rev
Author: mdboom
Date: 2008年07月01日 05:01:38 -0700 (2008年7月01日)
Log Message:
-----------
Remove autolayout.
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/mpl-data/matplotlib.conf.template
Modified: trunk/matplotlib/lib/matplotlib/mpl-data/matplotlib.conf.template
===================================================================
--- trunk/matplotlib/lib/matplotlib/mpl-data/matplotlib.conf.template	2008年07月01日 12:01:27 UTC (rev 5703)
+++ trunk/matplotlib/lib/matplotlib/mpl-data/matplotlib.conf.template	2008年07月01日 12:01:38 UTC (rev 5704)
@@ -3,32 +3,32 @@
 # This is a sample matplotlib configuration file. It should be placed
 # in HOME/.matplotlib (unix/linux like systems) and
 # C:\Documents and Settings\yourname\.matplotlib (win32 systems)
-# 
+#
 # By default, the installer will overwrite the existing file in the install
 # path, so if you want to preserve yours, please move it to your HOME dir and
 # set the environment variable if necessary.
-# 
+#
 # This file is best viewed in a editor which supports ini or conf mode syntax
 # highlighting.
-# 
+#
 # Blank lines, or lines starting with a comment symbol, are ignored,
 # as are trailing comments. Other lines must have the format
-# 
+#
 # key = val optional comment
-# 
+#
 # val should be valid python syntax, just as you would use when setting
 # properties using rcParams. This should become more obvious by inspecting
 # the default values listed herein.
-# 
+#
 # Colors: for the color values below, you can either use
 # - a matplotlib color string, such as r | k | b
 # - an rgb tuple, such as (1.0, 0.5, 0.0)
 # - a hex string, such as #ff00ff or ff00ff
 # - a scalar grayscale intensity such as 0.75
 # - a legal html color name, eg red | blue | darkslategray
-# 
+#
 # Interactivity: see http://matplotlib.sourceforge.net/interactive.html.
-# 
+#
 # ### CONFIGURATION BEGINS HERE ###
 
 # a value of type 'str'
@@ -42,7 +42,7 @@
 # 'Africa/Abidjan' or 'Africa/Accra' or 'Africa/Addis_Ababa' or
 # 'Africa/Algiers' or 'Africa/Asmara' or 'Africa/Asmera' or 'Africa/Bamako' or
 # 'Africa/Bangui' or 'Africa/Banjul' or 'Africa/Bissau' or 'Africa/Blantyre'
-# <...snipped 156 lines...> 
+# <...snipped 156 lines...>
 # 'US/Michigan' or 'US/Mountain' or 'US/Pacific' or 'US/Pacific-New' or
 # 'US/Samoa' or 'UTC' or 'Universal' or 'W-SU' or 'WET' or 'Zulu' or
 # 'posixrules'
@@ -145,8 +145,6 @@
 negative_linestyle = 'dashed'
 
 [figure]
- # a boolean
- autolayout = False
 # a float
 dpi = 80
 # any valid matplotlib color, eg an abbreviation like 'r' for red, a full
@@ -219,7 +217,7 @@
 # 'Accent' or 'Accent_r' or 'Blues' or 'Blues_r' or 'BrBG' or 'BrBG_r' or
 # 'BuGn' or 'BuGn_r' or 'BuPu' or 'BuPu_r' or 'Dark2' or 'Dark2_r' or
 # 'GnBu' or 'GnBu_r' or 'Greens' or 'Greens_r' or 'Greys' or 'Greys_r' or
- # <...snipped 16 lines...> 
+ # <...snipped 16 lines...>
 # 'pink_r' or 'prism' or 'prism_r' or 'spectral' or 'spectral_r' or
 # 'spring' or 'spring_r' or 'summer' or 'summer_r' or 'winter' or
 # 'winter_r'
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <md...@us...> - 2008年07月01日 12:01:29
Revision: 5703
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5703&view=rev
Author: mdboom
Date: 2008年07月01日 05:01:27 -0700 (2008年7月01日)
Log Message:
-----------
docstring fixes.
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/path.py
Modified: trunk/matplotlib/lib/matplotlib/path.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/path.py	2008年07月01日 11:59:22 UTC (rev 5702)
+++ trunk/matplotlib/lib/matplotlib/path.py	2008年07月01日 12:01:27 UTC (rev 5703)
@@ -24,7 +24,7 @@
 
 These two arrays always have the same length in the first
 dimension. For example, to represent a cubic curve, you must
- provide three vertices as well as three codes "CURVE3".
+ provide three vertices as well as three codes ``CURVE3``.
 
 The code types are:
 
@@ -53,8 +53,8 @@
 Users of Path objects should not access the vertices and codes
 arrays directly. Instead, they should use :meth:`iter_segments`
 to get the vertex/code pairs. This is important, since many
- :class:`Path`s, as an optimization, do not store a codes array at
- all, but have a default one provided for them by
+ :class:`Path` objects, as an optimization, do not store a *codes*
+ at all, but have a default one provided for them by
 :meth:`iter_segments`.
 """
 
@@ -168,16 +168,16 @@
 if not len(vertices):
 return
 
- codes = self.codes
+ codes = self.codes
 len_vertices = len(vertices)
- isnan = np.isnan
- any = np.any
+ isnan = np.isnan
+ any = np.any
 
 NUM_VERTICES = self.NUM_VERTICES
- MOVETO = self.MOVETO
- LINETO = self.LINETO
- CLOSEPOLY = self.CLOSEPOLY
- STOP = self.STOP
+ MOVETO = self.MOVETO
+ LINETO = self.LINETO
+ CLOSEPOLY = self.CLOSEPOLY
+ STOP = self.STOP
 
 if codes is None:
 next_code = MOVETO
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <md...@us...> - 2008年07月01日 11:59:25
Revision: 5702
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5702&view=rev
Author: mdboom
Date: 2008年07月01日 04:59:22 -0700 (2008年7月01日)
Log Message:
-----------
Don't error on figure.autolayout -- just warn that it does nothing.
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/config/rcsetup.py
 trunk/matplotlib/lib/matplotlib/rcsetup.py
Modified: trunk/matplotlib/lib/matplotlib/config/rcsetup.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/config/rcsetup.py	2008年06月30日 23:14:42 UTC (rev 5701)
+++ trunk/matplotlib/lib/matplotlib/config/rcsetup.py	2008年07月01日 11:59:22 UTC (rev 5702)
@@ -83,6 +83,10 @@
 'None','classic','toolbar2',
 ], ignorecase=True)
 
+def validate_autolayout(v):
+ if v:
+ warnings.warn("figure.autolayout is not currently supported")
+
 class validate_nseq_float:
 def __init__(self, n):
 self.n = n
@@ -439,6 +443,7 @@
 'figure.dpi' : [80, validate_float], # DPI
 'figure.facecolor' : ['0.75', validate_color], # facecolor; scalar gray
 'figure.edgecolor' : ['w', validate_color], # edgecolor; white
+ 'figure.autolayout' : [False, validate_autolayout],
 
 'figure.subplot.left' : [0.125, ValidateInterval(0, 1, closedmin=False, closedmax=False)],
 'figure.subplot.right' : [0.9, ValidateInterval(0, 1, closedmin=False, closedmax=False)],
Modified: trunk/matplotlib/lib/matplotlib/rcsetup.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/rcsetup.py	2008年06月30日 23:14:42 UTC (rev 5701)
+++ trunk/matplotlib/lib/matplotlib/rcsetup.py	2008年07月01日 11:59:22 UTC (rev 5702)
@@ -14,6 +14,7 @@
 """
 
 import os
+import warnings
 from matplotlib.fontconfig_pattern import parse_fontconfig_pattern
 from matplotlib.colors import is_color_like
 
@@ -109,6 +110,10 @@
 'None','classic','toolbar2',
 ], ignorecase=True)
 
+def validate_autolayout(v):
+ if v:
+ warnings.warn("figure.autolayout is not currently supported")
+
 class validate_nseq_float:
 def __init__(self, n):
 self.n = n
@@ -449,6 +454,7 @@
 'figure.dpi' : [ 80, validate_float], # DPI
 'figure.facecolor' : [ '0.75', validate_color], # facecolor; scalar gray
 'figure.edgecolor' : [ 'w', validate_color], # edgecolor; white
+ 'figure.autolayout' : [ False, validate_autolayout],
 
 'figure.subplot.left' : [0.125, ValidateInterval(0, 1, closedmin=True, closedmax=True)],
 'figure.subplot.right' : [0.9, ValidateInterval(0, 1, closedmin=True, closedmax=True)],
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.

Showing results of 240

<< < 1 .. 8 9 10 (Page 10 of 10)
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /