Skip to content

Commit 11fdc78

Browse files
committed
pyplot.spy should set current image only if it is making an image
svn path=/trunk/matplotlib/; revision=8052
1 parent 0b794ed commit 11fdc78

File tree

2 files changed

+23
-19
lines changed

2 files changed

+23
-19
lines changed

boilerplate.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def %(func)s(%(argspec)s):
8686
'semilogx',
8787
'semilogy',
8888
'specgram',
89-
'spy',
89+
#'spy',
9090
'stem',
9191
'step',
9292
'vlines',
@@ -111,7 +111,7 @@ def %(func)s(%(argspec)s):
111111
'pcolor' : 'sci(%(ret)s)',
112112
'pcolormesh': 'sci(%(ret)s)',
113113
'imshow' : 'sci(%(ret)s)',
114-
'spy' : 'sci(%(ret)s)',
114+
#'spy' : 'sci(%(ret)s)', ### may return image or Line2D
115115
'quiver' : 'sci(%(ret)s)',
116116
'specgram' : 'sci(%(ret)s[-1])',
117117

lib/matplotlib/pyplot.py

+21-17
Original file line numberDiff line numberDiff line change
@@ -1600,6 +1600,27 @@ def autogen_docstring(base):
16001600
addendum = docstring.Appender(msg, '\n\n')
16011601
return lambda func: addendum(docstring.copy_dedent(base)(func))
16021602

1603+
1604+
# This function cannot be generated by boilerplate.py because it may
1605+
# return an image or a line.
1606+
@autogen_docstring(Axes.spy)
1607+
def spy(Z, precision=0, marker=None, markersize=None, aspect='equal', hold=None, **kwargs):
1608+
ax = gca()
1609+
# allow callers to override the hold state by passing hold=True|False
1610+
washold = ax.ishold()
1611+
1612+
if hold is not None:
1613+
ax.hold(hold)
1614+
try:
1615+
ret = ax.spy(Z, precision, marker, markersize, aspect, **kwargs)
1616+
draw_if_interactive()
1617+
finally:
1618+
ax.hold(washold)
1619+
if isinstance(ret, cm.ScalarMappable):
1620+
sci(ret)
1621+
return ret
1622+
1623+
16031624
## Plotting part 2: autogenerated wrappers for axes methods ##
16041625

16051626
# This function was autogenerated by boilerplate.py. Do not edit as
@@ -2252,23 +2273,6 @@ def specgram(x, NFFT=256, Fs=2, Fc=0, detrend=mlab.detrend_none, window=mlab.win
22522273
sci(ret[-1])
22532274
return ret
22542275

2255-
# This function was autogenerated by boilerplate.py. Do not edit as
2256-
# changes will be lost
2257-
@autogen_docstring(Axes.spy)
2258-
def spy(Z, precision=0, marker=None, markersize=None, aspect='equal', hold=None, **kwargs):
2259-
ax = gca()
2260-
# allow callers to override the hold state by passing hold=True|False
2261-
washold = ax.ishold()
2262-
2263-
if hold is not None:
2264-
ax.hold(hold)
2265-
try:
2266-
ret = ax.spy(Z, precision, marker, markersize, aspect, **kwargs)
2267-
draw_if_interactive()
2268-
finally:
2269-
ax.hold(washold)
2270-
sci(ret)
2271-
return ret
22722276

22732277
# This function was autogenerated by boilerplate.py. Do not edit as
22742278
# changes will be lost

0 commit comments

Comments
 (0)