Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6a70beb

Browse files
committed
Make all parameters of ColorbarBase, except ax, keyword-only.
This is consistent with Colorbar. Moreover, this will make it possibly to ultimately merge Colorbar into ColorbarBase -- currently, they only differ by the fact that a ColorbarBase doesn't have an associated ScalarMappable, but we can just construct an empty ScalarMappable in that case (this is already what we document as recommended approach to construct colorbars not attached to an artist -- `fig.colorbar(ScalarMappable(norm=..., cmap=...))`. Right now this merging is *nearly* possible except for the fact that the constructors' signatures are a pain to combine.
1 parent f369b10 commit 6a70beb

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

doc/api/api_changes_3.3/deprecations.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,3 +455,8 @@ replaced by calls to ``draw_idle()`` on the corresponding canvas.
455455
~~~~~~~~~~~~~~~~~~~~~~~~~~
456456
The ``add_checker`` and ``check_update`` methods and ``update_dict`` attribute
457457
of `.ScalarMappable` are deprecated.
458+
459+
``ColorbarBase`` parameters will become keyword-only
460+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
461+
All parameters of ``ColorbarBase``, except for the first (*ax*), will become
462+
keyword-only, consistently with ``Colorbar``.

lib/matplotlib/colorbar.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,7 @@ class ColorbarBase:
394394

395395
n_rasterize = 50 # rasterize solids if number of colors >= n_rasterize
396396

397+
@cbook._make_keyword_only("3.3", "cmap")
397398
def __init__(self, ax, cmap=None,
398399
norm=None,
399400
alpha=None,

lib/matplotlib/tests/test_colorbar.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ def test_remove_from_figure(use_gridspec):
226226
def test_colorbarbase():
227227
# smoke test from #3805
228228
ax = plt.gca()
229-
ColorbarBase(ax, plt.cm.bone)
229+
ColorbarBase(ax, cmap=plt.cm.bone)
230230

231231

232232
@image_comparison(['colorbar_closed_patch'], remove_text=True)

0 commit comments

Comments
 (0)