From b2eba0c8b79b5973021fa8d3d5cc7bcd62f39742 Mon Sep 17 00:00:00 2001 From: Eric Firing Date: Sun, 18 Mar 2018 17:35:00 -1000 Subject: [PATCH 1/2] DOC: Make colorbar tutorial examples look like colorbars. - Give the colorbars a reasonable aspect ratio. - Fix a link. - Other minor edits. --- tutorials/colors/colorbar_only.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/tutorials/colors/colorbar_only.py b/tutorials/colors/colorbar_only.py index 08616d1cd202..fec31ae34ad9 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') @@ -88,7 +90,8 @@ # colorbar with discrete intervals. To make the length of each extension 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']) From 72f829581dd263f39359dcfab2bed810b0785221 Mon Sep 17 00:00:00 2001 From: Eric Firing Date: Sun, 18 Mar 2018 19:59:56 -1000 Subject: [PATCH 2/2] fix a typo in the text --- tutorials/colors/colorbar_only.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tutorials/colors/colorbar_only.py b/tutorials/colors/colorbar_only.py index fec31ae34ad9..3f211e42dbc0 100644 --- a/tutorials/colors/colorbar_only.py +++ b/tutorials/colors/colorbar_only.py @@ -87,8 +87,8 @@ # -------------------------------------- # # 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(figsize=(6, 1)) fig.subplots_adjust(bottom=0.5)