@@ -1221,13 +1221,13 @@ def colorbar(
1221
1221
1222
1222
The *shrink* kwarg provides a simple way to scale the colorbar with
1223
1223
respect to the axes. Note that if *cax* is specified, it determines the
1224
- size of the colorbar and *shrink* and *aspect* kwargs are ignored.
1224
+ size of the colorbar, and *shrink* and *aspect* are ignored.
1225
1225
1226
1226
For more precise control, you can manually specify the positions of the
1227
1227
axes objects in which the mappable and the colorbar are drawn. In this
1228
1228
case, do not use any of the axes properties kwargs.
1229
1229
1230
- It is known that some vector graphics viewers (svg and pdf) renders
1230
+ It is known that some vector graphics viewers (svg and pdf) render
1231
1231
white gaps between segments of the colorbar. This is due to bugs in
1232
1232
the viewers, not Matplotlib. As a workaround, the colorbar can be
1233
1233
rendered with overlapping segments::
@@ -1257,27 +1257,18 @@ def colorbar(
1257
1257
'the Colorbar, provide the *ax* argument to steal space '
1258
1258
'from it, or add *mappable* to an Axes.' ))
1259
1259
ax = self .gca ()
1260
- current_ax = self .gca ()
1261
- userax = False
1262
1260
if (use_gridspec
1263
1261
and isinstance (ax , mpl .axes ._base ._AxesBase )
1264
1262
and ax .get_subplotspec ()):
1265
1263
cax , kwargs = cbar .make_axes_gridspec (ax , ** kwargs )
1266
1264
else :
1267
1265
cax , kwargs = cbar .make_axes (ax , ** kwargs )
1268
1266
cax .grid (visible = False , which = 'both' , axis = 'both' )
1269
- else :
1270
- userax = True
1271
-
1272
- # need to remove kws that cannot be passed to Colorbar
1273
- NON_COLORBAR_KEYS = ['fraction' , 'pad' , 'shrink' , 'aspect' , 'anchor' ,
1274
- 'panchor' ]
1275
- cb_kw = {k : v for k , v in kwargs .items () if k not in NON_COLORBAR_KEYS }
1276
-
1277
- cb = cbar .Colorbar (cax , mappable , ** cb_kw )
1278
1267
1279
- if not userax :
1280
- self .sca (current_ax )
1268
+ NON_COLORBAR_KEYS = [ # remove kws that cannot be passed to Colorbar
1269
+ 'fraction' , 'pad' , 'shrink' , 'aspect' , 'anchor' , 'panchor' ]
1270
+ cb = cbar .Colorbar (cax , mappable , ** {
1271
+ k : v for k , v in kwargs .items () if k not in NON_COLORBAR_KEYS })
1281
1272
self .stale = True
1282
1273
return cb
1283
1274
0 commit comments