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

Skip to content

Commit be7422b

Browse files
committed
Prefer colorbar(ScalarMappable(...)) to ColorbarBase in tutorial.
Nearly all the colorbar_only tutorial already uses `colorbar(ScalarMappable(...))` to generate "standalone" colorbars; change the last example that was still using `ColorbarBase`.
1 parent 8c2fbda commit be7422b

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

tutorials/colors/colorbar_only.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,10 @@
5252
cmap = mpl.cm.viridis
5353
bounds = [-1, 2, 5, 7, 12, 15]
5454
norm = mpl.colors.BoundaryNorm(bounds, cmap.N, extend='both')
55-
cb2 = mpl.colorbar.ColorbarBase(ax, cmap=cmap,
56-
norm=norm,
57-
orientation='horizontal')
58-
cb2.set_label("Discrete intervals with extend='both' keyword")
59-
fig.show()
55+
56+
fig.colorbar(mpl.cm.ScalarMappable(norm=norm, cmap=cmap),
57+
cax=ax, orientation='horizontal',
58+
label="Discrete intervals with extend='both' keyword")
6059

6160
###############################################################################
6261
# Discrete intervals colorbar

0 commit comments

Comments
 (0)