8000 Update example · matplotlib/matplotlib@754fd26 · GitHub
[go: up one dir, main page]

Skip to content

Commit 754fd26

Browse files
fmaussionefiring
authored andcommitted
Update example
1 parent 3638d42 commit 754fd26

File tree

2 files changed

+20
-90
lines changed

2 files changed

+20
-90
lines changed

examples/api/colorbar_only.py

Lines changed: 0 additions & 90 deletions
This file was deleted.

tutorials/colors/colorbar_only.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,26 @@
3838
fig.colorbar(mpl.cm.ScalarMappable(norm=norm, cmap=cmap),
3939
cax=ax, orientation='horizontal', label='Some Units')
4040

41+
42+
###############################################################################
43+
# Extended colorbar with continuous colorscale
44+
# --------------------------------------------
45+
46+
# The second example shows how to make a discrete colorbar based on a
47+
# continuous cmap. With the "extend" kwarg the appropriate colors are chosen to
48+
# fill the colorspace, including the extensions:
49+
fig, ax = plt.subplots(figsize=(6, 1))
50+
fig.subplots_adjust(bottom=0.5)
51+
52+
cmap = mpl.cm.viridis
53+
bounds = [-1, 2, 5, 7, 12, 15]
54+
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()
60+
4161
###############################################################################
4262
# Discrete intervals colorbar
4363
# ---------------------------

0 commit comments

Comments
 (0)
0