File tree Expand file tree Collapse file tree 2 files changed +8
-3
lines changed Expand file tree Collapse file tree 2 files changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -1253,11 +1253,13 @@ def colorbar(
12531253 # Store the value of gca so that we can set it back later on.
12541254 if cax is None :
12551255 if ax is None :
1256- raise ValueError (
1256+ _api . warn_deprecated ( 3.6 , message = (
12571257 'Unable to determine Axes to steal space for Colorbar. '
1258+ 'Using gca(), but will raise in the future. '
12581259 'Either provide the *cax* argument to use as the Axes for '
12591260 '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 ()
12611263 current_ax = self .gca ()
12621264 userax = False
12631265 if (use_gridspec and isinstance (ax , SubplotBase )):
Original file line number Diff line number Diff line change 11import numpy as np
22import pytest
33
4+ from matplotlib import _api
45from matplotlib import cm
56import matplotlib .colors as mcolors
67import matplotlib as mpl
78
9+
810from matplotlib import rc_context
911from matplotlib .testing .decorators import image_comparison
1012import matplotlib .pyplot as plt
@@ -319,7 +321,8 @@ def test_parentless_mappable():
319321 pc = mpl .collections .PatchCollection ([], cmap = plt .get_cmap ('viridis' ))
320322 pc .set_array ([])
321323
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' ):
323326 plt .colorbar (pc )
324327
325328
You can’t perform that action at this time.
0 commit comments