Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e88094a

Browse files
committed
Replace old spy and spy2 with new spy (briefly called spy3)
svn path=/trunk/matplotlib/; revision=2915
1 parent 6af8acd commit e88094a

5 files changed

Lines changed: 10 additions & 1107 deletions

File tree

CHANGELOG

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
2006-12-09 Replaced spy and spy2 with the new spy that combines
2+
marker and image capabilities - EF
3+
14
2006-12-09 Added support for plotting 2-D arrays with plot:
25
columns are plotted as in Matlab - EF
36

boilerplate.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ def %(func)s(*args, **kwargs):
7878
'semilogy',
7979
'specgram',
8080
'spy',
81-
'spy2',
8281
'stem',
8382
'vlines',
8483
'quiver',
@@ -102,7 +101,7 @@ def %(func)s(*args, **kwargs):
102101
'pcolor' : 'gci._current = ret',
103102
'pcolormesh' : 'gci._current = ret',
104103
'imshow' : 'gci._current = ret',
105-
'spy2' : 'gci._current = ret',
104+
'spy' : 'gci._current = ret',
106105
'quiver2' : 'gci._current = ret',
107106
'quiver' : 'gci._current = ret',
108107
'specgram' : 'gci._current = ret[-1]',

examples/spy_demos.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
ax1.spy(x, markersize=5)
1818
ax2.spy(x, precision=0.1, markersize=5)
1919

20-
ax3.spy2(x, aspect='auto', origin='lower')
21-
ax4.spy2(x, precision=0.1, aspect='auto', origin='lower')
20+
ax3.spy(x)
21+
ax4.spy(x, precision=0.1)
2222

2323
show()

lib/matplotlib/axes.py

Lines changed: 1 addition & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -4397,66 +4397,7 @@ def specgram(self, x, NFFT=256, Fs=2, detrend=detrend_none,
43974397

43984398
return Pxx, freqs, bins, im
43994399

4400-
def spy(self, Z, marker='s', markersize=10, precision=None, **kwargs):
4401-
"""
4402-
SPY(Z, **kwargs) plots the sparsity pattern of the matrix Z
4403-
using plot markers.
4404-
4405-
The line handles are returned
4406-
4407-
if precision is None, any non-zero value will be plotted
4408-
if precision is not None, values of absolute(Z)>precision will be plotted
4409-
4410-
kwargs control the Line2D properties of the markers:
4411-
%(Line2D)s
4412-
"""
4413-
if hasattr(Z, 'tocoo'):
4414-
c = Z.tocoo()
4415-
x = c.row
4416-
y = c.col
4417-
z = c.data
4418-
else:
4419-
Z = asarray(Z)
4420-
if precision is None: mask = Z!=0.
4421-
else: mask = absolute(Z)>precision
4422-
x,y,z = matplotlib.mlab.get_xyz_where(Z, mask)
4423-
return self.plot(x+0.5,y+0.5, linestyle='None',
4424-
marker=marker,markersize=markersize, **kwargs)
4425-
spy.__doc__ = spy.__doc__%artist.kwdocd
4426-
4427-
def spy2(self, Z, precision=None, **kwargs):
4428-
"""
4429-
SPY2(Z) plots the sparsity pattern of the matrix Z as an image
4430-
4431-
if precision is None, any non-zero value will be plotted
4432-
if precision is not None, values of absolute(Z)>precision will be plotted
4433-
4434-
kwargs are passed on to imshow; see help imshow for valid kwargs
4435-
4436-
The image instance is returned
4437-
"""
4438-
4439-
#binary colormap min white, max black
4440-
Z = asarray(Z)
4441-
4442-
if precision is None: mask = Z!=0.
4443-
else: mask = absolute(Z)>precision
4444-
4445-
Z = where(mask, 1., 0.)
4446-
4447-
kwargs = kwargs.copy()
4448-
if 'cmap' not in kwargs:
4449-
cmapdata = {
4450-
'red' : ((0., 1., 1.), (1., 0., 0.)),
4451-
'green': ((0., 1., 1.), (1., 0., 0.)),
4452-
'blue' : ((0., 1., 1.), (1., 0., 0.))
4453-
}
4454-
binary = LinearSegmentedColormap('binary', cmapdata, 2)
4455-
kwargs['cmap'] = binary
4456-
4457-
return self.imshow(transpose(Z), interpolation='nearest', **kwargs)
4458-
4459-
def spy3(self, Z, precision=None, marker=None, markersize=None,
4400+
def spy(self, Z, precision=None, marker=None, markersize=None,
44604401
aspect='equal', **kwargs):
44614402
"""
44624403
spy(Z) plots the sparsity pattern of the 2-D array Z

0 commit comments

Comments
 (0)