|
10 | 10 |
|
11 | 11 | :class:`~matplotlib.colorbar.ColorbarBase` derives from |
12 | 12 | :mod:`~matplotlib.cm.ScalarMappable` and puts a colorbar in a specified axes, |
13 | | -so it has everything needed for a standalone colorbar. It can be used as is to |
14 | | -make a colorbar for a given colormap and does not need a mappable object like |
| 13 | +so it has everything needed for a standalone colorbar. It can be used as-is to |
| 14 | +make a colorbar for a given colormap; it does not need a mappable object like |
15 | 15 | an image. In this tutorial we will explore what can be done with standalone |
16 | 16 | colorbar. |
17 | 17 |
|
|
22 | 22 | will be used. Then create the colorbar by calling |
23 | 23 | :class:`~matplotlib.colorbar.ColorbarBase` and specify axis, colormap, norm |
24 | 24 | and orientation as parameters. Here we create a basic continuous colorbar |
25 | | -with ticks and labels. More information on colorbar api can be found |
26 | | -`here <https://matplotlib.org/api/colorbar_api.html>`. |
| 25 | +with ticks and labels. More information on the colorbar API can be found |
| 26 | +`here <https://matplotlib.org/api/colorbar_api.html>`_. |
27 | 27 | """ |
28 | 28 |
|
29 | 29 | import matplotlib.pyplot as plt |
30 | 30 | import matplotlib as mpl |
31 | 31 |
|
32 | | -fig, ax = plt.subplots() |
| 32 | +fig, ax = plt.subplots(figsize=(6, 1)) |
| 33 | +fig.subplots_adjust(bottom=0.5) |
33 | 34 |
|
34 | 35 | cmap = mpl.cm.cool |
35 | 36 | norm = mpl.colors.Normalize(vmin=5, vmax=10) |
|
62 | 63 | # *extend*, you must specify two extra boundaries. Finally spacing argument |
63 | 64 | # ensures that intervals are shown on colorbar proportionally. |
64 | 65 |
|
65 | | -fig, ax = plt.subplots() |
| 66 | +fig, ax = plt.subplots(figsize=(6, 1)) |
| 67 | +fig.subplots_adjust(bottom=0.5) |
66 | 68 |
|
67 | 69 | cmap = mpl.colors.ListedColormap(['red', 'green', 'blue', 'cyan']) |
68 | 70 | cmap.set_over('0.25') |
|
85 | 87 | # -------------------------------------- |
86 | 88 | # |
87 | 89 | # Here we illustrate the use of custom length colorbar extensions, used on a |
88 | | -# colorbar with discrete intervals. To make the length of each extension same |
89 | | -# as the length of the interior colors, use ``extendfrac='auto'``. |
| 90 | +# colorbar with discrete intervals. To make the length of each extension the |
| 91 | +# same as the length of the interior colors, use ``extendfrac='auto'``. |
90 | 92 |
|
91 | | -fig, ax = plt.subplots() |
| 93 | +fig, ax = plt.subplots(figsize=(6, 1)) |
| 94 | +fig.subplots_adjust(bottom=0.5) |
92 | 95 |
|
93 | 96 | cmap = mpl.colors.ListedColormap(['royalblue', 'cyan', |
94 | 97 | 'yellow', 'orange']) |
|
0 commit comments