Skip to content

Commit

Permalink
Merge Colorbar and ColorbarBase.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
anntzer committed Jun 18, 2021
1 parent f008953 commit b84775c
Show file tree
Hide file tree
Showing 6 changed files with 162 additions and 178 deletions.
4 changes: 2 additions & 2 deletions doc/users/prev_whats_new/whats_new_3.0.rst
Expand Up @@ -60,11 +60,11 @@ frame. Padding and separation parameters can be adjusted.
Add ``minorticks_on()/off()`` methods for colorbar
--------------------------------------------------

A new method `~.colorbar.ColorbarBase.minorticks_on` has been added to
A new method ``ColorbarBase.minorticks_on`` has been added to
correctly display minor ticks on a colorbar. This method doesn't allow the
minor ticks to extend into the regions beyond vmin and vmax when the *extend*
keyword argument (used while creating the colorbar) is set to 'both', 'max' or
'min'. A complementary method `~.colorbar.ColorbarBase.minorticks_off` has
'min'. A complementary method ``ColorbarBase.minorticks_off`` has
also been added to remove the minor ticks on the colorbar.


Expand Down
2 changes: 1 addition & 1 deletion doc/users/prev_whats_new/whats_new_3.3.0.rst
Expand Up @@ -285,7 +285,7 @@ Align labels to Axes edges
--------------------------

`~.axes.Axes.set_xlabel`, `~.axes.Axes.set_ylabel` and
`.ColorbarBase.set_label` support a parameter ``loc`` for simplified
``ColorbarBase.set_label`` support a parameter ``loc`` for simplified
positioning. For the xlabel, the supported values are 'left', 'center', or
'right'. For the ylabel, the supported values are 'bottom', 'center', or
'top'.
Expand Down
4 changes: 2 additions & 2 deletions examples/color/colorbar_basics.py
Expand Up @@ -54,5 +54,5 @@
#
# - `matplotlib.axes.Axes.imshow` / `matplotlib.pyplot.imshow`
# - `matplotlib.figure.Figure.colorbar` / `matplotlib.pyplot.colorbar`
# - `matplotlib.colorbar.ColorbarBase.minorticks_on`
# - `matplotlib.colorbar.ColorbarBase.minorticks_off`
# - `matplotlib.colorbar.Colorbar.minorticks_on`
# - `matplotlib.colorbar.Colorbar.minorticks_off`
2 changes: 1 addition & 1 deletion examples/images_contours_and_fields/image_masked.py
Expand Up @@ -79,4 +79,4 @@
# - `matplotlib.axes.Axes.imshow` / `matplotlib.pyplot.imshow`
# - `matplotlib.figure.Figure.colorbar` / `matplotlib.pyplot.colorbar`
# - `matplotlib.colors.BoundaryNorm`
# - `matplotlib.colorbar.ColorbarBase.set_label`
# - `matplotlib.colorbar.Colorbar.set_label`

0 comments on commit b84775c

Please sign in to comment.