diff --git a/tutorials/colors/colorbar_only.py b/tutorials/colors/colorbar_only.py index 08616d1cd202..3f211e42dbc0 100644 --- a/tutorials/colors/colorbar_only.py +++ b/tutorials/colors/colorbar_only.py @@ -10,8 +10,8 @@ :class:`~matplotlib.colorbar.ColorbarBase` derives from :mod:`~matplotlib.cm.ScalarMappable` and puts a colorbar in a specified axes, -so it has everything needed for a standalone colorbar. It can be used as is to -make a colorbar for a given colormap and does not need a mappable object like +so it has everything needed for a standalone colorbar. It can be used as-is to +make a colorbar for a given colormap; it does not need a mappable object like an image. In this tutorial we will explore what can be done with standalone colorbar. @@ -22,14 +22,15 @@ will be used. Then create the colorbar by calling :class:`~matplotlib.colorbar.ColorbarBase` and specify axis, colormap, norm and orientation as parameters. Here we create a basic continuous colorbar -with ticks and labels. More information on colorbar api can be found -`here `. +with ticks and labels. More information on the colorbar API can be found +`here `_. """ import matplotlib.pyplot as plt import matplotlib as mpl -fig, ax = plt.subplots() +fig, ax = plt.subplots(figsize=(6, 1)) +fig.subplots_adjust(bottom=0.5) cmap = mpl.cm.cool norm = mpl.colors.Normalize(vmin=5, vmax=10) @@ -62,7 +63,8 @@ # *extend*, you must specify two extra boundaries. Finally spacing argument # ensures that intervals are shown on colorbar proportionally. -fig, ax = plt.subplots() +fig, ax = plt.subplots(figsize=(6, 1)) +fig.subplots_adjust(bottom=0.5) cmap = mpl.colors.ListedColormap(['red', 'green', 'blue', 'cyan']) cmap.set_over('0.25') @@ -85,10 +87,11 @@ # -------------------------------------- # # Here we illustrate the use of custom length colorbar extensions, used on a -# colorbar with discrete intervals. To make the length of each extension same -# as the length of the interior colors, use ``extendfrac='auto'``. +# colorbar with discrete intervals. To make the length of each extension the +# same as the length of the interior colors, use ``extendfrac='auto'``. -fig, ax = plt.subplots() +fig, ax = plt.subplots(figsize=(6, 1)) +fig.subplots_adjust(bottom=0.5) cmap = mpl.colors.ListedColormap(['royalblue', 'cyan', 'yellow', 'orange'])