Merge Colorbar and ColorbarBase. · matplotlib/matplotlib@5f1165f · GitHub
Skip to content

Commit 5f1165f

Browse files
committed
Merge Colorbar and ColorbarBase.
ColorbarBase differs from Colorbar in that it is not associated with a ScalarMappable (but constructed from explicit cmap/norm), but we already document in Figure.colorbar that the preferred way to draw colorbars not associated with an existing artist is to create an empty ScalarMappable to provide `norm` and `cmap`. Hence, likewise merge Colorbar and ColorbarBase (creating the ScalarMappable on-the-fly if no mappable is passed to the constructor), which should make the APIs clearer. (Note that we are already discouraging users to directly call either class' constructors, anyways). We could deprecate the backcompat APIs (i.e., the `ColorbarBase` alias, the `cmap` and `norm` kwargs, and the different semantics of `add_lines`), but that can be done later; this PR should be entirely backcompatible.
1 parent f008953 commit 5f1165f

6 files changed

Lines changed: 165 additions & 178 deletions

File tree

doc/users/prev_whats_new/whats_new_3.0.rst

Lines changed: 2 additions & 2 deletions

doc/users/prev_whats_new/whats_new_3.3.0.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ Align labels to Axes edges
285285
--------------------------
286286

287287
`~.axes.Axes.set_xlabel`, `~.axes.Axes.set_ylabel` and
288-
`.ColorbarBase.set_label` support a parameter ``loc`` for simplified
288+
``ColorbarBase.set_label`` support a parameter ``loc`` for simplified
289289
positioning. For the xlabel, the supported values are 'left', 'center', or
290290
'right'. For the ylabel, the supported values are 'bottom', 'center', or
291291
'top'.

examples/color/colorbar_basics.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,5 @@
5454
#
5555
# - `matplotlib.axes.Axes.imshow` / `matplotlib.pyplot.imshow`
5656
# - `matplotlib.figure.Figure.colorbar` / `matplotlib.pyplot.colorbar`
57-
# - `matplotlib.colorbar.ColorbarBase.minorticks_on`
58-
# - `matplotlib.colorbar.ColorbarBase.minorticks_off`
57+
# - `matplotlib.colorbar.Colorbar.minorticks_on`
58+
# - `matplotlib.colorbar.Colorbar.minorticks_off`

examples/images_contours_and_fields/image_masked.py

Lines changed: 1 addition & 1 deletion

0 commit comments

Comments
 (0)