@@ -129,8 +129,10 @@ def rcdefaults():
129129 matplotlib .rcdefaults ()
130130 draw_if_interactive ()
131131
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+
134136def gci ():
135137 """
136138 Get the current :class:`~matplotlib.cm.ScalarMappable` instance
@@ -142,18 +144,20 @@ def gci():
142144 :func:`~matplotlib.pyplot.pcolor` and
143145 :func:`~matplotlib.pyplot.scatter` create
144146 :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.
145150 """
146- return gci ._current
147- gci ._current = None
148-
151+ return gcf ()._gci ()
149152
150153def sci (im ):
151154 """
152155 Set the current image (target of colormap commands like
153156 :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.
155159 """
156- gci . _current = im
160+ gca (). _sci ( im )
157161
158162
159163## Any Artist ##
@@ -1598,7 +1602,6 @@ def autogen_docstring(base):
15981602
15991603## Plotting part 2: autogenerated wrappers for axes methods ##
16001604
1601-
16021605# This function was autogenerated by boilerplate.py. Do not edit as
16031606# changes will be lost
16041607@autogen_docstring (Axes .acorr )
@@ -1830,7 +1833,7 @@ def contour(*args, **kwargs):
18301833 draw_if_interactive ()
18311834 finally :
18321835 ax .hold (washold )
1833- if ret ._A is not None : gci . _current = ret
1836+ if ret ._A is not None : sci ( ret )
18341837 return ret
18351838
18361839# This function was autogenerated by boilerplate.py. Do not edit as
@@ -1848,7 +1851,7 @@ def contourf(*args, **kwargs):
18481851 draw_if_interactive ()
18491852 finally :
18501853 ax .hold (washold )
1851- if ret ._A is not None : gci . _current = ret
1854+ if ret ._A is not None : sci ( ret )
18521855 return ret
18531856
18541857# 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
19561959 draw_if_interactive ()
19571960 finally :
19581961 ax .hold (washold )
1959- gci . _current = ret
1962+ sci ( ret )
19601963 return ret
19611964
19621965# 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,
20102013 draw_if_interactive ()
20112014 finally :
20122015 ax .hold (washold )
2013- gci . _current = ret
2016+ sci ( ret )
20142017 return ret
20152018
20162019# This function was autogenerated by boilerplate.py. Do not edit as
@@ -2046,7 +2049,7 @@ def pcolor(*args, **kwargs):
20462049 draw_if_interactive ()
20472050 finally :
20482051 ax .hold (washold )
2049- gci . _current = ret
2052+ sci ( ret )
20502053 return ret
20512054
20522055# This function was autogenerated by boilerplate.py. Do not edit as
@@ -2064,7 +2067,7 @@ def pcolormesh(*args, **kwargs):
20642067 draw_if_interactive ()
20652068 finally :
20662069 ax .hold (washold )
2067- gci . _current = ret
2070+ sci ( ret )
20682071 return ret
20692072
20702073# This function was autogenerated by boilerplate.py. Do not edit as
@@ -2154,7 +2157,7 @@ def quiver(*args, **kw):
21542157 draw_if_interactive ()
21552158 finally :
21562159 ax .hold (washold )
2157- gci . _current = ret
2160+ sci ( ret )
21582161 return ret
21592162
21602163# 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
21902193 draw_if_interactive ()
21912194 finally :
21922195 ax .hold (washold )
2193- gci . _current = ret
2196+ sci ( ret )
21942197 return ret
21952198
21962199# 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
22442247 draw_if_interactive ()
22452248 finally :
22462249 ax .hold (washold )
2247- gci . _current = ret [- 1 ]
2250+ sci ( ret [- 1 ])
22482251 return ret
22492252
22502253# 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,
22622265 draw_if_interactive ()
22632266 finally :
22642267 ax .hold (washold )
2265- gci . _current = ret
2268+ sci ( ret )
22662269 return ret
22672270
22682271# This function was autogenerated by boilerplate.py. Do not edit as
@@ -2628,3 +2631,5 @@ def spectral():
26282631 draw_if_interactive ()
26292632
26302633
2634+
2635+
0 commit comments