File tree 2 files changed +8
-3
lines changed
2 files changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -1253,11 +1253,13 @@ def colorbar(
1253
1253
# Store the value of gca so that we can set it back later on.
1254
1254
if cax is None :
1255
1255
if ax is None :
1256
- raise ValueError (
1256
+ _api . warn_deprecated ( 3.6 , message = (
1257
1257
'Unable to determine Axes to steal space for Colorbar. '
1258
+ 'Using gca(), but will raise in the future. '
1258
1259
'Either provide the *cax* argument to use as the Axes for '
1259
1260
'the Colorbar, provide the *ax* argument to steal space '
1260
- 'from it, or add *mappable* to an Axes.' )
1261
+ 'from it, or add *mappable* to an Axes.' ))
1262
+ ax = self .gca ()
1261
1263
current_ax = self .gca ()
1262
1264
userax = False
1263
1265
if (use_gridspec and isinstance (ax , SubplotBase )):
Original file line number Diff line number Diff line change 1
1
import numpy as np
2
2
import pytest
3
3
4
+ from matplotlib import _api
4
5
from matplotlib import cm
5
6
import matplotlib .colors as mcolors
6
7
import matplotlib as mpl
7
8
9
+
8
10
from matplotlib import rc_context
9
11
from matplotlib .testing .decorators import image_comparison
10
12
import matplotlib .pyplot as plt
@@ -319,7 +321,8 @@ def test_parentless_mappable():
319
321
pc = mpl .collections .PatchCollection ([], cmap = plt .get_cmap ('viridis' ))
320
322
pc .set_array ([])
321
323
322
- with pytest .raises (ValueError , match = 'Unable to determine Axes to steal' ):
324
+ with pytest .warns (_api .MatplotlibDeprecationWarning ,
325
+ match = 'Unable to determine Axes to steal' ):
323
326
plt .colorbar (pc )
324
327
325
328
You can’t perform that action at this time.
0 commit comments