@@ -129,8 +129,10 @@ def rcdefaults():
129
129
matplotlib .rcdefaults ()
130
130
draw_if_interactive ()
131
131
132
- # The current "image" (ScalarMappable) is tracked here on a
133
- # per-pylab-session basis:
132
+ # The current "image" (ScalarMappable) is retrieved or set
133
+ # only via the pyplot interface using the following two
134
+ # functions:
135
+
134
136
def gci ():
135
137
"""
136
138
Get the current :class:`~matplotlib.cm.ScalarMappable` instance
@@ -142,18 +144,20 @@ def gci():
142
144
:func:`~matplotlib.pyplot.pcolor` and
143
145
:func:`~matplotlib.pyplot.scatter` create
144
146
:class:`~matplotlib.collections.Collection` instances.
147
+ The current image is an attribute of the current axes, or the
148
+ nearest earlier axes in the current figure that contains an
149
+ image.
145
150
"""
146
- return gci ._current
147
- gci ._current = None
148
-
151
+ return gcf ()._gci ()
149
152
150
153
def sci (im ):
151
154
"""
152
155
Set the current image (target of colormap commands like
153
156
:func:`~matplotlib.pyplot.jet`, :func:`~matplotlib.pyplot.hot` or
154
- :func:`~matplotlib.pyplot.clim`).
157
+ :func:`~matplotlib.pyplot.clim`). The current image is an
158
+ attribute of the current axes.
155
159
"""
156
- gci . _current = im
160
+ gca (). _sci ( im )
157
161
158
162
159
163
## Any Artist ##
@@ -1598,7 +1602,6 @@ def autogen_docstring(base):
1598
1602
1599
1603
## Plotting part 2: autogenerated wrappers for axes methods ##
1600
1604
1601
-
1602
1605
# This function was autogenerated by boilerplate.py. Do not edit as
1603
1606
# changes will be lost
1604
1607
@autogen_docstring (Axes .acorr )
@@ -1830,7 +1833,7 @@ def contour(*args, **kwargs):
1830
1833
draw_if_interactive ()
1831
1834
finally :
1832
1835
ax .hold (washold )
1833
- if ret ._A is not None : gci . _current = ret
1836
+ if ret ._A is not None : sci ( ret )
1834
1837
return ret
1835
1838
1836
1839
# This function was autogenerated by boilerplate.py. Do not edit as
@@ -1848,7 +1851,7 @@ def contourf(*args, **kwargs):
1848
1851
draw_if_interactive ()
1849
1852
finally :
1850
1853
ax .hold (washold )
1851
- if ret ._A is not None : gci . _current = ret
1854
+ if ret ._A is not None : sci ( ret )
1852
1855
return ret
1853
1856
1854
1857
# This function was autogenerated by boilerplate.py. Do not edit as
@@ -1956,7 +1959,7 @@ def hexbin(x, y, C=None, gridsize=100, bins=None, xscale='linear', yscale='linea
1956
1959
draw_if_interactive ()
1957
1960
finally :
1958
1961
ax .hold (washold )
1959
- gci . _current = ret
1962
+ sci ( ret )
1960
1963
return ret
1961
1964
1962
1965
# This function was autogenerated by boilerplate.py. Do not edit as
@@ -2010,7 +2013,7 @@ def imshow(X, cmap=None, norm=None, aspect=None, interpolation=None, alpha=1.0,
2010
2013
draw_if_interactive ()
2011
2014
finally :
2012
2015
ax .hold (washold )
2013
- gci . _current = ret
2016
+ sci ( ret )
2014
2017
return ret
2015
2018
2016
2019
# This function was autogenerated by boilerplate.py. Do not edit as
@@ -2046,7 +2049,7 @@ def pcolor(*args, **kwargs):
2046
2049
draw_if_interactive ()
2047
2050
finally :
2048
2051
ax .hold (washold )
2049
- gci . _current = ret
2052
+ sci ( ret )
2050
2053
return ret
2051
2054
2052
2055
# This function was autogenerated by boilerplate.py. Do not edit as
@@ -2064,7 +2067,7 @@ def pcolormesh(*args, **kwargs):
2064
2067
draw_if_interactive ()
2065
2068
finally :
2066
2069
ax .hold (washold )
2067
- gci . _current = ret
2070
+ sci ( ret )
2068
2071
return ret
2069
2072
2070
2073
# This function was autogenerated by boilerplate.py. Do not edit as
@@ -2154,7 +2157,7 @@ def quiver(*args, **kw):
2154
2157
draw_if_interactive ()
2155
2158
finally :
2156
2159
ax .hold (washold )
2157
- gci . _current = ret
2160
+ sci ( ret )
2158
2161
return ret
2159
2162
2160
2163
# This function was autogenerated by boilerplate.py. Do not edit as
@@ -2190,7 +2193,7 @@ def scatter(x, y, s=20, c='b', marker='o', cmap=None, norm=None, vmin=None, vmax
2190
2193
draw_if_interactive ()
2191
2194
finally :
2192
2195
ax .hold (washold )
2193
- gci . _current = ret
2196
+ sci ( ret )
2194
2197
return ret
2195
2198
2196
2199
# This function was autogenerated by boilerplate.py. Do not edit as
@@ -2244,7 +2247,7 @@ def specgram(x, NFFT=256, Fs=2, Fc=0, detrend=mlab.detrend_none, window=mlab.win
2244
2247
draw_if_interactive ()
2245
2248
finally :
2246
2249
ax .hold (washold )
2247
- gci . _current = ret [- 1 ]
2250
+ sci ( ret [- 1 ])
2248
2251
return ret
2249
2252
2250
2253
# This function was autogenerated by boilerplate.py. Do not edit as
@@ -2262,7 +2265,7 @@ def spy(Z, precision=0, marker=None, markersize=None, aspect='equal', hold=None,
2262
2265
draw_if_interactive ()
2263
2266
finally :
2264
2267
ax .hold (washold )
2265
- gci . _current = ret
2268
+ sci ( ret )
2266
2269
return ret
2267
2270
2268
2271
# This function was autogenerated by boilerplate.py. Do not edit as
@@ -2628,3 +2631,5 @@ def spectral():
2628
2631
draw_if_interactive ()
2629
2632
2630
2633
2634
+
2635
+
0 commit comments