From 087f31219c66baf54776843466f36b19e350eba6 Mon Sep 17 00:00:00 2001
From: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com>
Date: Wed, 24 Jan 2018 03:13:51 +0100
Subject: [PATCH] improve code generated by boilerplate.py

---
 lib/matplotlib/pyplot.py | 535 +++++++++++++++------------------------
 tools/boilerplate.py     |  42 ++-
 2 files changed, 223 insertions(+), 354 deletions(-)

diff --git a/lib/matplotlib/pyplot.py b/lib/matplotlib/pyplot.py
index 22ed435b059e..b07c354adef4 100644
--- a/lib/matplotlib/pyplot.py
+++ b/lib/matplotlib/pyplot.py
@@ -2505,8 +2505,7 @@ def spy(Z, precision=0, marker=None, markersize=None, aspect='equal', **kwargs):
 ################# REMAINING CONTENT GENERATED BY boilerplate.py ##############
 
 
-# This function was autogenerated by boilerplate.py.  Do not edit as
-# changes will be lost
+# Autogenerated by boilerplate.py.  Do not edit as changes will be lost.
 @_autogen_docstring(Axes.acorr)
 def acorr(x, hold=None, data=None, **kwargs):
     ax = gca()
@@ -2526,8 +2525,7 @@ def acorr(x, hold=None, data=None, **kwargs):
 
     return ret
 
-# This function was autogenerated by boilerplate.py.  Do not edit as
-# changes will be lost
+# Autogenerated by boilerplate.py.  Do not edit as changes will be lost.
 @_autogen_docstring(Axes.angle_spectrum)
 def angle_spectrum(x, Fs=None, Fc=None, window=None, pad_to=None, sides=None,
                    hold=None, data=None, **kwargs):
@@ -2549,8 +2547,7 @@ def angle_spectrum(x, Fs=None, Fc=None, window=None, pad_to=None, sides=None,
 
     return ret
 
-# This function was autogenerated by boilerplate.py.  Do not edit as
-# changes will be lost
+# Autogenerated by boilerplate.py.  Do not edit as changes will be lost.
 @_autogen_docstring(Axes.arrow)
 def arrow(x, y, dx, dy, hold=None, **kwargs):
     ax = gca()
@@ -2570,8 +2567,7 @@ def arrow(x, y, dx, dy, hold=None, **kwargs):
 
     return ret
 
-# This function was autogenerated by boilerplate.py.  Do not edit as
-# changes will be lost
+# Autogenerated by boilerplate.py.  Do not edit as changes will be lost.
 @_autogen_docstring(Axes.axhline)
 def axhline(y=0, xmin=0, xmax=1, hold=None, **kwargs):
     ax = gca()
@@ -2591,8 +2587,7 @@ def axhline(y=0, xmin=0, xmax=1, hold=None, **kwargs):
 
     return ret
 
-# This function was autogenerated by boilerplate.py.  Do not edit as
-# changes will be lost
+# Autogenerated by boilerplate.py.  Do not edit as changes will be lost.
 @_autogen_docstring(Axes.axhspan)
 def axhspan(ymin, ymax, xmin=0, xmax=1, hold=None, **kwargs):
     ax = gca()
@@ -2612,8 +2607,7 @@ def axhspan(ymin, ymax, xmin=0, xmax=1, hold=None, **kwargs):
 
     return ret
 
-# This function was autogenerated by boilerplate.py.  Do not edit as
-# changes will be lost
+# Autogenerated by boilerplate.py.  Do not edit as changes will be lost.
 @_autogen_docstring(Axes.axvline)
 def axvline(x=0, ymin=0, ymax=1, hold=None, **kwargs):
     ax = gca()
@@ -2633,8 +2627,7 @@ def axvline(x=0, ymin=0, ymax=1, hold=None, **kwargs):
 
     return ret
 
-# This function was autogenerated by boilerplate.py.  Do not edit as
-# changes will be lost
+# Autogenerated by boilerplate.py.  Do not edit as changes will be lost.
 @_autogen_docstring(Axes.axvspan)
 def axvspan(xmin, xmax, ymin=0, ymax=1, hold=None, **kwargs):
     ax = gca()
@@ -2654,8 +2647,7 @@ def axvspan(xmin, xmax, ymin=0, ymax=1, hold=None, **kwargs):
 
     return ret
 
-# This function was autogenerated by boilerplate.py.  Do not edit as
-# changes will be lost
+# Autogenerated by boilerplate.py.  Do not edit as changes will be lost.
 @_autogen_docstring(Axes.bar)
 def bar(*args, **kwargs):
     ax = gca()
@@ -2675,8 +2667,7 @@ def bar(*args, **kwargs):
 
     return ret
 
-# This function was autogenerated by boilerplate.py.  Do not edit as
-# changes will be lost
+# Autogenerated by boilerplate.py.  Do not edit as changes will be lost.
 @_autogen_docstring(Axes.barh)
 def barh(*args, **kwargs):
     ax = gca()
@@ -2696,8 +2687,7 @@ def barh(*args, **kwargs):
 
     return ret
 
-# This function was autogenerated by boilerplate.py.  Do not edit as
-# changes will be lost
+# Autogenerated by boilerplate.py.  Do not edit as changes will be lost.
 @_autogen_docstring(Axes.broken_barh)
 def broken_barh(xranges, yrange, hold=None, data=None, **kwargs):
     ax = gca()
@@ -2717,8 +2707,7 @@ def broken_barh(xranges, yrange, hold=None, data=None, **kwargs):
 
     return ret
 
-# This function was autogenerated by boilerplate.py.  Do not edit as
-# changes will be lost
+# Autogenerated by boilerplate.py.  Do not edit as changes will be lost.
 @_autogen_docstring(Axes.boxplot)
 def boxplot(x, notch=None, sym=None, vert=None, whis=None, positions=None,
             widths=None, patch_artist=None, bootstrap=None, usermedians=None,
@@ -2756,8 +2745,7 @@ def boxplot(x, notch=None, sym=None, vert=None, whis=None, positions=None,
 
     return ret
 
-# This function was autogenerated by boilerplate.py.  Do not edit as
-# changes will be lost
+# Autogenerated by boilerplate.py.  Do not edit as changes will be lost.
 @_autogen_docstring(Axes.cohere)
 def cohere(x, y, NFFT=256, Fs=2, Fc=0, detrend=mlab.detrend_none,
            window=mlab.window_hanning, noverlap=0, pad_to=None, sides='default',
@@ -2782,8 +2770,7 @@ def cohere(x, y, NFFT=256, Fs=2, Fc=0, detrend=mlab.detrend_none,
 
     return ret
 
-# This function was autogenerated by boilerplate.py.  Do not edit as
-# changes will be lost
+# Autogenerated by boilerplate.py.  Do not edit as changes will be lost.
 @_autogen_docstring(Axes.clabel)
 def clabel(CS, *args, **kwargs):
     ax = gca()
@@ -2803,8 +2790,7 @@ def clabel(CS, *args, **kwargs):
 
     return ret
 
-# This function was autogenerated by boilerplate.py.  Do not edit as
-# changes will be lost
+# Autogenerated by boilerplate.py.  Do not edit as changes will be lost.
 @_autogen_docstring(Axes.contour)
 def contour(*args, **kwargs):
     ax = gca()
@@ -2824,8 +2810,7 @@ def contour(*args, **kwargs):
     if ret._A is not None: sci(ret)
     return ret
 
-# This function was autogenerated by boilerplate.py.  Do not edit as
-# changes will be lost
+# Autogenerated by boilerplate.py.  Do not edit as changes will be lost.
 @_autogen_docstring(Axes.contourf)
 def contourf(*args, **kwargs):
     ax = gca()
@@ -2845,8 +2830,7 @@ def contourf(*args, **kwargs):
     if ret._A is not None: sci(ret)
     return ret
 
-# This function was autogenerated by boilerplate.py.  Do not edit as
-# changes will be lost
+# Autogenerated by boilerplate.py.  Do not edit as changes will be lost.
 @_autogen_docstring(Axes.csd)
 def csd(x, y, NFFT=None, Fs=None, Fc=None, detrend=None, window=None,
         noverlap=None, pad_to=None, sides=None, scale_by_freq=None,
@@ -2871,8 +2855,7 @@ def csd(x, y, NFFT=None, Fs=None, Fc=None, detrend=None, window=None,
 
     return ret
 
-# This function was autogenerated by boilerplate.py.  Do not edit as
-# changes will be lost
+# Autogenerated by boilerplate.py.  Do not edit as changes will be lost.
 @_autogen_docstring(Axes.errorbar)
 def errorbar(x, y, yerr=None, xerr=None, fmt='', ecolor=None, elinewidth=None,
              capsize=None, barsabove=False, lolims=False, uplims=False,
@@ -2900,8 +2883,7 @@ def errorbar(x, y, yerr=None, xerr=None, fmt='', ecolor=None, elinewidth=None,
 
     return ret
 
-# This function was autogenerated by boilerplate.py.  Do not edit as
-# changes will be lost
+# Autogenerated by boilerplate.py.  Do not edit as changes will be lost.
 @_autogen_docstring(Axes.eventplot)
 def eventplot(positions, orientation='horizontal', lineoffsets=1, linelengths=1,
               linewidths=None, colors=None, linestyles='solid', hold=None,
@@ -2926,8 +2908,7 @@ def eventplot(positions, orientation='horizontal', lineoffsets=1, linelengths=1,
 
     return ret
 
-# This function was autogenerated by boilerplate.py.  Do not edit as
-# changes will be lost
+# Autogenerated by boilerplate.py.  Do not edit as changes will be lost.
 @_autogen_docstring(Axes.fill)
 def fill(*args, **kwargs):
     ax = gca()
@@ -2947,8 +2928,7 @@ def fill(*args, **kwargs):
 
     return ret
 
-# This function was autogenerated by boilerplate.py.  Do not edit as
-# changes will be lost
+# Autogenerated by boilerplate.py.  Do not edit as changes will be lost.
 @_autogen_docstring(Axes.fill_between)
 def fill_between(x, y1, y2=0, where=None, interpolate=False, step=None,
                  hold=None, data=None, **kwargs):
@@ -2971,8 +2951,7 @@ def fill_between(x, y1, y2=0, where=None, interpolate=False, step=None,
 
     return ret
 
-# This function was autogenerated by boilerplate.py.  Do not edit as
-# changes will be lost
+# Autogenerated by boilerplate.py.  Do not edit as changes will be lost.
 @_autogen_docstring(Axes.fill_betweenx)
 def fill_betweenx(y, x1, x2=0, where=None, step=None, interpolate=False,
                   hold=None, data=None, **kwargs):
@@ -2994,8 +2973,7 @@ def fill_betweenx(y, x1, x2=0, where=None, step=None, interpolate=False,
 
     return ret
 
-# This function was autogenerated by boilerplate.py.  Do not edit as
-# changes will be lost
+# Autogenerated by boilerplate.py.  Do not edit as changes will be lost.
 @_autogen_docstring(Axes.hexbin)
 def hexbin(x, y, C=None, gridsize=100, bins=None, xscale='linear',
            yscale='linear', extent=None, cmap=None, norm=None, vmin=None,
@@ -3024,8 +3002,7 @@ def hexbin(x, y, C=None, gridsize=100, bins=None, xscale='linear',
     sci(ret)
     return ret
 
-# This function was autogenerated by boilerplate.py.  Do not edit as
-# changes will be lost
+# Autogenerated by boilerplate.py.  Do not edit as changes will be lost.
 @_autogen_docstring(Axes.hist)
 def hist(x, bins=None, range=None, density=None, weights=None, cumulative=False,
          bottom=None, histtype='bar', align='mid', orientation='vertical',
@@ -3052,8 +3029,7 @@ def hist(x, bins=None, range=None, density=None, weights=None, cumulative=False,
 
     return ret
 
-# This function was autogenerated by boilerplate.py.  Do not edit as
-# changes will be lost
+# Autogenerated by boilerplate.py.  Do not edit as changes will be lost.
 @_autogen_docstring(Axes.hist2d)
 def hist2d(x, y, bins=10, range=None, normed=False, weights=None, cmin=None,
            cmax=None, hold=None, data=None, **kwargs):
@@ -3076,8 +3052,7 @@ def hist2d(x, y, bins=10, range=None, normed=False, weights=None, cmin=None,
     sci(ret[-1])
     return ret
 
-# This function was autogenerated by boilerplate.py.  Do not edit as
-# changes will be lost
+# Autogenerated by boilerplate.py.  Do not edit as changes will be lost.
 @_autogen_docstring(Axes.hlines)
 def hlines(y, xmin, xmax, colors='k', linestyles='solid', label='', hold=None,
            data=None, **kwargs):
@@ -3099,8 +3074,7 @@ def hlines(y, xmin, xmax, colors='k', linestyles='solid', label='', hold=None,
 
     return ret
 
-# This function was autogenerated by boilerplate.py.  Do not edit as
-# changes will be lost
+# Autogenerated by boilerplate.py.  Do not edit as changes will be lost.
 @_autogen_docstring(Axes.imshow)
 def imshow(X, cmap=None, norm=None, aspect=None, interpolation=None, alpha=None,
            vmin=None, vmax=None, origin=None, extent=None, shape=None,
@@ -3128,8 +3102,7 @@ def imshow(X, cmap=None, norm=None, aspect=None, interpolation=None, alpha=None,
     sci(ret)
     return ret
 
-# This function was autogenerated by boilerplate.py.  Do not edit as
-# changes will be lost
+# Autogenerated by boilerplate.py.  Do not edit as changes will be lost.
 @_autogen_docstring(Axes.loglog)
 def loglog(*args, **kwargs):
     ax = gca()
@@ -3149,8 +3122,7 @@ def loglog(*args, **kwargs):
 
     return ret
 
-# This function was autogenerated by boilerplate.py.  Do not edit as
-# changes will be lost
+# Autogenerated by boilerplate.py.  Do not edit as changes will be lost.
 @_autogen_docstring(Axes.magnitude_spectrum)
 def magnitude_spectrum(x, Fs=None, Fc=None, window=None, pad_to=None,
                        sides=None, scale=None, hold=None, data=None, **kwargs):
@@ -3173,8 +3145,7 @@ def magnitude_spectrum(x, Fs=None, Fc=None, window=None, pad_to=None,
 
     return ret
 
-# This function was autogenerated by boilerplate.py.  Do not edit as
-# changes will be lost
+# Autogenerated by boilerplate.py.  Do not edit as changes will be lost.
 @_autogen_docstring(Axes.pcolor)
 def pcolor(*args, **kwargs):
     ax = gca()
@@ -3194,8 +3165,7 @@ def pcolor(*args, **kwargs):
     sci(ret)
     return ret
 
-# This function was autogenerated by boilerplate.py.  Do not edit as
-# changes will be lost
+# Autogenerated by boilerplate.py.  Do not edit as changes will be lost.
 @_autogen_docstring(Axes.pcolormesh)
 def pcolormesh(*args, **kwargs):
     ax = gca()
@@ -3215,8 +3185,7 @@ def pcolormesh(*args, **kwargs):
     sci(ret)
     return ret
 
-# This function was autogenerated by boilerplate.py.  Do not edit as
-# changes will be lost
+# Autogenerated by boilerplate.py.  Do not edit as changes will be lost.
 @_autogen_docstring(Axes.phase_spectrum)
 def phase_spectrum(x, Fs=None, Fc=None, window=None, pad_to=None, sides=None,
                    hold=None, data=None, **kwargs):
@@ -3238,8 +3207,7 @@ def phase_spectrum(x, Fs=None, Fc=None, window=None, pad_to=None, sides=None,
 
     return ret
 
-# This function was autogenerated by boilerplate.py.  Do not edit as
-# changes will be lost
+# Autogenerated by boilerplate.py.  Do not edit as changes will be lost.
 @_autogen_docstring(Axes.pie)
 def pie(x, explode=None, labels=None, colors=None, autopct=None,
         pctdistance=0.6, shadow=False, labeldistance=1.1, startangle=None,
@@ -3267,8 +3235,7 @@ def pie(x, explode=None, labels=None, colors=None, autopct=None,
 
     return ret
 
-# This function was autogenerated by boilerplate.py.  Do not edit as
-# changes will be lost
+# Autogenerated by boilerplate.py.  Do not edit as changes will be lost.
 @_autogen_docstring(Axes.plot)
 def plot(*args, **kwargs):
     ax = gca()
@@ -3288,8 +3255,7 @@ def plot(*args, **kwargs):
 
     return ret
 
-# This function was autogenerated by boilerplate.py.  Do not edit as
-# changes will be lost
+# Autogenerated by boilerplate.py.  Do not edit as changes will be lost.
 @_autogen_docstring(Axes.plot_date)
 def plot_date(x, y, fmt='o', tz=None, xdate=True, ydate=False, hold=None,
               data=None, **kwargs):
@@ -3311,8 +3277,7 @@ def plot_date(x, y, fmt='o', tz=None, xdate=True, ydate=False, hold=None,
 
     return ret
 
-# This function was autogenerated by boilerplate.py.  Do not edit as
-# changes will be lost
+# Autogenerated by boilerplate.py.  Do not edit as changes will be lost.
 @_autogen_docstring(Axes.psd)
 def psd(x, NFFT=None, Fs=None, Fc=None, detrend=None, window=None,
         noverlap=None, pad_to=None, sides=None, scale_by_freq=None,
@@ -3337,8 +3302,7 @@ def psd(x, NFFT=None, Fs=None, Fc=None, detrend=None, window=None,
 
     return ret
 
-# This function was autogenerated by boilerplate.py.  Do not edit as
-# changes will be lost
+# Autogenerated by boilerplate.py.  Do not edit as changes will be lost.
 @_autogen_docstring(Axes.quiver)
 def quiver(*args, **kw):
     ax = gca()
@@ -3358,8 +3322,7 @@ def quiver(*args, **kw):
     sci(ret)
     return ret
 
-# This function was autogenerated by boilerplate.py.  Do not edit as
-# changes will be lost
+# Autogenerated by boilerplate.py.  Do not edit as changes will be lost.
 @_autogen_docstring(Axes.quiverkey)
 def quiverkey(*args, **kw):
     ax = gca()
@@ -3379,8 +3342,7 @@ def quiverkey(*args, **kw):
 
     return ret
 
-# This function was autogenerated by boilerplate.py.  Do not edit as
-# changes will be lost
+# Autogenerated by boilerplate.py.  Do not edit as changes will be lost.
 @_autogen_docstring(Axes.scatter)
 def scatter(x, y, s=None, c=None, marker=None, cmap=None, norm=None, vmin=None,
             vmax=None, alpha=None, linewidths=None, verts=None, edgecolors=None,
@@ -3405,8 +3367,7 @@ def scatter(x, y, s=None, c=None, marker=None, cmap=None, norm=None, vmin=None,
     sci(ret)
     return ret
 
-# This function was autogenerated by boilerplate.py.  Do not edit as
-# changes will be lost
+# Autogenerated by boilerplate.py.  Do not edit as changes will be lost.
 @_autogen_docstring(Axes.semilogx)
 def semilogx(*args, **kwargs):
     ax = gca()
@@ -3426,8 +3387,7 @@ def semilogx(*args, **kwargs):
 
     return ret
 
-# This function was autogenerated by boilerplate.py.  Do not edit as
-# changes will be lost
+# Autogenerated by boilerplate.py.  Do not edit as changes will be lost.
 @_autogen_docstring(Axes.semilogy)
 def semilogy(*args, **kwargs):
     ax = gca()
@@ -3447,8 +3407,7 @@ def semilogy(*args, **kwargs):
 
     return ret
 
-# This function was autogenerated by boilerplate.py.  Do not edit as
-# changes will be lost
+# Autogenerated by boilerplate.py.  Do not edit as changes will be lost.
 @_autogen_docstring(Axes.specgram)
 def specgram(x, NFFT=None, Fs=None, Fc=None, detrend=None, window=None,
              noverlap=None, cmap=None, xextent=None, pad_to=None, sides=None,
@@ -3475,8 +3434,7 @@ def specgram(x, NFFT=None, Fs=None, Fc=None, detrend=None, window=None,
     sci(ret[-1])
     return ret
 
-# This function was autogenerated by boilerplate.py.  Do not edit as
-# changes will be lost
+# Autogenerated by boilerplate.py.  Do not edit as changes will be lost.
 @_autogen_docstring(Axes.stackplot)
 def stackplot(x, *args, **kwargs):
     ax = gca()
@@ -3496,8 +3454,7 @@ def stackplot(x, *args, **kwargs):
 
     return ret
 
-# This function was autogenerated by boilerplate.py.  Do not edit as
-# changes will be lost
+# Autogenerated by boilerplate.py.  Do not edit as changes will be lost.
 @_autogen_docstring(Axes.stem)
 def stem(*args, **kwargs):
     ax = gca()
@@ -3517,8 +3474,7 @@ def stem(*args, **kwargs):
 
     return ret
 
-# This function was autogenerated by boilerplate.py.  Do not edit as
-# changes will be lost
+# Autogenerated by boilerplate.py.  Do not edit as changes will be lost.
 @_autogen_docstring(Axes.step)
 def step(x, y, *args, **kwargs):
     ax = gca()
@@ -3538,8 +3494,7 @@ def step(x, y, *args, **kwargs):
 
     return ret
 
-# This function was autogenerated by boilerplate.py.  Do not edit as
-# changes will be lost
+# Autogenerated by boilerplate.py.  Do not edit as changes will be lost.
 @_autogen_docstring(Axes.streamplot)
 def streamplot(x, y, u, v, density=1, linewidth=None, color=None, cmap=None,
                norm=None, arrowsize=1, arrowstyle='-|>', minlength=0.1,
@@ -3569,8 +3524,7 @@ def streamplot(x, y, u, v, density=1, linewidth=None, color=None, cmap=None,
     sci(ret.lines)
     return ret
 
-# This function was autogenerated by boilerplate.py.  Do not edit as
-# changes will be lost
+# Autogenerated by boilerplate.py.  Do not edit as changes will be lost.
 @_autogen_docstring(Axes.tricontour)
 def tricontour(*args, **kwargs):
     ax = gca()
@@ -3590,8 +3544,7 @@ def tricontour(*args, **kwargs):
     if ret._A is not None: sci(ret)
     return ret
 
-# This function was autogenerated by boilerplate.py.  Do not edit as
-# changes will be lost
+# Autogenerated by boilerplate.py.  Do not edit as changes will be lost.
 @_autogen_docstring(Axes.tricontourf)
 def tricontourf(*args, **kwargs):
     ax = gca()
@@ -3611,8 +3564,7 @@ def tricontourf(*args, **kwargs):
     if ret._A is not None: sci(ret)
     return ret
 
-# This function was autogenerated by boilerplate.py.  Do not edit as
-# changes will be lost
+# Autogenerated by boilerplate.py.  Do not edit as changes will be lost.
 @_autogen_docstring(Axes.tripcolor)
 def tripcolor(*args, **kwargs):
     ax = gca()
@@ -3632,8 +3584,7 @@ def tripcolor(*args, **kwargs):
     sci(ret)
     return ret
 
-# This function was autogenerated by boilerplate.py.  Do not edit as
-# changes will be lost
+# Autogenerated by boilerplate.py.  Do not edit as changes will be lost.
 @_autogen_docstring(Axes.triplot)
 def triplot(*args, **kwargs):
     ax = gca()
@@ -3653,8 +3604,7 @@ def triplot(*args, **kwargs):
 
     return ret
 
-# This function was autogenerated by boilerplate.py.  Do not edit as
-# changes will be lost
+# Autogenerated by boilerplate.py.  Do not edit as changes will be lost.
 @_autogen_docstring(Axes.violinplot)
 def violinplot(dataset, positions=None, vert=True, widths=0.5, showmeans=False,
                showextrema=True, showmedians=False, points=100, bw_method=None,
@@ -3679,8 +3629,7 @@ def violinplot(dataset, positions=None, vert=True, widths=0.5, showmeans=False,
 
     return ret
 
-# This function was autogenerated by boilerplate.py.  Do not edit as
-# changes will be lost
+# Autogenerated by boilerplate.py.  Do not edit as changes will be lost.
 @_autogen_docstring(Axes.vlines)
 def vlines(x, ymin, ymax, colors='k', linestyles='solid', label='', hold=None,
            data=None, **kwargs):
@@ -3702,8 +3651,7 @@ def vlines(x, ymin, ymax, colors='k', linestyles='solid', label='', hold=None,
 
     return ret
 
-# This function was autogenerated by boilerplate.py.  Do not edit as
-# changes will be lost
+# Autogenerated by boilerplate.py.  Do not edit as changes will be lost.
 @_autogen_docstring(Axes.xcorr)
 def xcorr(x, y, normed=True, detrend=mlab.detrend_none, usevlines=True,
           maxlags=10, hold=None, data=None, **kwargs):
@@ -3726,8 +3674,7 @@ def xcorr(x, y, normed=True, detrend=mlab.detrend_none, usevlines=True,
 
     return ret
 
-# This function was autogenerated by boilerplate.py.  Do not edit as
-# changes will be lost
+# Autogenerated by boilerplate.py.  Do not edit as changes will be lost.
 @_autogen_docstring(Axes.barbs)
 def barbs(*args, **kw):
     ax = gca()
@@ -3747,367 +3694,295 @@ def barbs(*args, **kw):
 
     return ret
 
-# This function was autogenerated by boilerplate.py.  Do not edit as
-# changes will be lost
+# Autogenerated by boilerplate.py.  Do not edit as changes will be lost.
 @docstring.copy_dedent(Axes.cla)
 def cla():
     ret = gca().cla()
     return ret
 
-# This function was autogenerated by boilerplate.py.  Do not edit as
-# changes will be lost
+# Autogenerated by boilerplate.py.  Do not edit as changes will be lost.
 @docstring.copy_dedent(Axes.grid)
 def grid(b=None, which='major', axis='both', **kwargs):
     ret = gca().grid(b=b, which=which, axis=axis, **kwargs)
     return ret
 
-# This function was autogenerated by boilerplate.py.  Do not edit as
-# changes will be lost
+# Autogenerated by boilerplate.py.  Do not edit as changes will be lost.
 @docstring.copy_dedent(Axes.legend)
 def legend(*args, **kwargs):
     ret = gca().legend(*args, **kwargs)
     return ret
 
-# This function was autogenerated by boilerplate.py.  Do not edit as
-# changes will be lost
+# Autogenerated by boilerplate.py.  Do not edit as changes will be lost.
 @docstring.copy_dedent(Axes.table)
 def table(**kwargs):
     ret = gca().table(**kwargs)
     return ret
 
-# This function was autogenerated by boilerplate.py.  Do not edit as
-# changes will be lost
+# Autogenerated by boilerplate.py.  Do not edit as changes will be lost.
 @docstring.copy_dedent(Axes.text)
 def text(x, y, s, fontdict=None, withdash=False, **kwargs):
     ret = gca().text(x, y, s, fontdict=fontdict, withdash=withdash, **kwargs)
     return ret
 
-# This function was autogenerated by boilerplate.py.  Do not edit as
-# changes will be lost
+# Autogenerated by boilerplate.py.  Do not edit as changes will be lost.
 @docstring.copy_dedent(Axes.annotate)
 def annotate(*args, **kwargs):
     ret = gca().annotate(*args, **kwargs)
     return ret
 
-# This function was autogenerated by boilerplate.py.  Do not edit as
-# changes will be lost
+# Autogenerated by boilerplate.py.  Do not edit as changes will be lost.
 @docstring.copy_dedent(Axes.ticklabel_format)
 def ticklabel_format(**kwargs):
     ret = gca().ticklabel_format(**kwargs)
     return ret
 
-# This function was autogenerated by boilerplate.py.  Do not edit as
-# changes will be lost
+# Autogenerated by boilerplate.py.  Do not edit as changes will be lost.
 @docstring.copy_dedent(Axes.locator_params)
 def locator_params(axis='both', tight=None, **kwargs):
     ret = gca().locator_params(axis=axis, tight=tight, **kwargs)
     return ret
 
-# This function was autogenerated by boilerplate.py.  Do not edit as
-# changes will be lost
+# Autogenerated by boilerplate.py.  Do not edit as changes will be lost.
 @docstring.copy_dedent(Axes.tick_params)
 def tick_params(axis='both', **kwargs):
     ret = gca().tick_params(axis=axis, **kwargs)
     return ret
 
-# This function was autogenerated by boilerplate.py.  Do not edit as
-# changes will be lost
+# Autogenerated by boilerplate.py.  Do not edit as changes will be lost.
 @docstring.copy_dedent(Axes.margins)
 def margins(*args, **kw):
     ret = gca().margins(*args, **kw)
     return ret
 
-# This function was autogenerated by boilerplate.py.  Do not edit as
-# changes will be lost
+# Autogenerated by boilerplate.py.  Do not edit as changes will be lost.
 @docstring.copy_dedent(Axes.autoscale)
 def autoscale(enable=True, axis='both', tight=None):
     ret = gca().autoscale(enable=enable, axis=axis, tight=tight)
     return ret
 
-# This function was autogenerated by boilerplate.py.  Do not edit as
-# changes will be lost
+# Autogenerated by boilerplate.py.  Do not edit as changes will be lost.
 def autumn():
-    '''
-    set the default colormap to autumn and apply to current image if any.
-    See help(colormaps) for more information
-    '''
-    rc('image', cmap='autumn')
-    im = gci()
+    """
+    Set the colormap to "autumn".
 
-    if im is not None:
-        im.set_cmap(cm.autumn)
+    This changes the default colormap as well as the colormap of the current
+    image if there is one. See ``help(colormaps)`` for more information.
+    """
+    set_cmap("autumn")
 
 
-# This function was autogenerated by boilerplate.py.  Do not edit as
-# changes will be lost
+# Autogenerated by boilerplate.py.  Do not edit as changes will be lost.
 def bone():
-    '''
-    set the default colormap to bone and apply to current image if any.
-    See help(colormaps) for more information
-    '''
-    rc('image', cmap='bone')
-    im = gci()
+    """
+    Set the colormap to "bone".
 
-    if im is not None:
-        im.set_cmap(cm.bone)
+    This changes the default colormap as well as the colormap of the current
+    image if there is one. See ``help(colormaps)`` for more information.
+    """
+    set_cmap("bone")
 
 
-# This function was autogenerated by boilerplate.py.  Do not edit as
-# changes will be lost
+# Autogenerated by boilerplate.py.  Do not edit as changes will be lost.
 def cool():
-    '''
-    set the default colormap to cool and apply to current image if any.
-    See help(colormaps) for more information
-    '''
-    rc('image', cmap='cool')
-    im = gci()
+    """
+    Set the colormap to "cool".
 
-    if im is not None:
-        im.set_cmap(cm.cool)
+    This changes the default colormap as well as the colormap of the current
+    image if there is one. See ``help(colormaps)`` for more information.
+    """
+    set_cmap("cool")
 
 
-# This function was autogenerated by boilerplate.py.  Do not edit as
-# changes will be lost
+# Autogenerated by boilerplate.py.  Do not edit as changes will be lost.
 def copper():
-    '''
-    set the default colormap to copper and apply to current image if any.
-    See help(colormaps) for more information
-    '''
-    rc('image', cmap='copper')
-    im = gci()
+    """
+    Set the colormap to "copper".
 
-    if im is not None:
-        im.set_cmap(cm.copper)
+    This changes the default colormap as well as the colormap of the current
+    image if there is one. See ``help(colormaps)`` for more information.
+    """
+    set_cmap("copper")
 
 
-# This function was autogenerated by boilerplate.py.  Do not edit as
-# changes will be lost
+# Autogenerated by boilerplate.py.  Do not edit as changes will be lost.
 def flag():
-    '''
-    set the default colormap to flag and apply to current image if any.
-    See help(colormaps) for more information
-    '''
-    rc('image', cmap='flag')
-    im = gci()
+    """
+    Set the colormap to "flag".
 
-    if im is not None:
-        im.set_cmap(cm.flag)
+    This changes the default colormap as well as the colormap of the current
+    image if there is one. See ``help(colormaps)`` for more information.
+    """
+    set_cmap("flag")
 
 
-# This function was autogenerated by boilerplate.py.  Do not edit as
-# changes will be lost
+# Autogenerated by boilerplate.py.  Do not edit as changes will be lost.
 def gray():
-    '''
-    set the default colormap to gray and apply to current image if any.
-    See help(colormaps) for more information
-    '''
-    rc('image', cmap='gray')
-    im = gci()
+    """
+    Set the colormap to "gray".
 
-    if im is not None:
-        im.set_cmap(cm.gray)
+    This changes the default colormap as well as the colormap of the current
+    image if there is one. See ``help(colormaps)`` for more information.
+    """
+    set_cmap("gray")
 
 
-# This function was autogenerated by boilerplate.py.  Do not edit as
-# changes will be lost
+# Autogenerated by boilerplate.py.  Do not edit as changes will be lost.
 def hot():
-    '''
-    set the default colormap to hot and apply to current image if any.
-    See help(colormaps) for more information
-    '''
-    rc('image', cmap='hot')
-    im = gci()
+    """
+    Set the colormap to "hot".
 
-    if im is not None:
-        im.set_cmap(cm.hot)
+    This changes the default colormap as well as the colormap of the current
+    image if there is one. See ``help(colormaps)`` for more information.
+    """
+    set_cmap("hot")
 
 
-# This function was autogenerated by boilerplate.py.  Do not edit as
-# changes will be lost
+# Autogenerated by boilerplate.py.  Do not edit as changes will be lost.
 def hsv():
-    '''
-    set the default colormap to hsv and apply to current image if any.
-    See help(colormaps) for more information
-    '''
-    rc('image', cmap='hsv')
-    im = gci()
+    """
+    Set the colormap to "hsv".
 
-    if im is not None:
-        im.set_cmap(cm.hsv)
+    This changes the default colormap as well as the colormap of the current
+    image if there is one. See ``help(colormaps)`` for more information.
+    """
+    set_cmap("hsv")
 
 
-# This function was autogenerated by boilerplate.py.  Do not edit as
-# changes will be lost
+# Autogenerated by boilerplate.py.  Do not edit as changes will be lost.
 def jet():
-    '''
-    set the default colormap to jet and apply to current image if any.
-    See help(colormaps) for more information
-    '''
-    rc('image', cmap='jet')
-    im = gci()
+    """
+    Set the colormap to "jet".
 
-    if im is not None:
-        im.set_cmap(cm.jet)
+    This changes the default colormap as well as the colormap of the current
+    image if there is one. See ``help(colormaps)`` for more information.
+    """
+    set_cmap("jet")
 
 
-# This function was autogenerated by boilerplate.py.  Do not edit as
-# changes will be lost
+# Autogenerated by boilerplate.py.  Do not edit as changes will be lost.
 def pink():
-    '''
-    set the default colormap to pink and apply to current image if any.
-    See help(colormaps) for more information
-    '''
-    rc('image', cmap='pink')
-    im = gci()
+    """
+    Set the colormap to "pink".
 
-    if im is not None:
-        im.set_cmap(cm.pink)
+    This changes the default colormap as well as the colormap of the current
+    image if there is one. See ``help(colormaps)`` for more information.
+    """
+    set_cmap("pink")
 
 
-# This function was autogenerated by boilerplate.py.  Do not edit as
-# changes will be lost
+# Autogenerated by boilerplate.py.  Do not edit as changes will be lost.
 def prism():
-    '''
-    set the default colormap to prism and apply to current image if any.
-    See help(colormaps) for more information
-    '''
-    rc('image', cmap='prism')
-    im = gci()
+    """
+    Set the colormap to "prism".
 
-    if im is not None:
-        im.set_cmap(cm.prism)
+    This changes the default colormap as well as the colormap of the current
+    image if there is one. See ``help(colormaps)`` for more information.
+    """
+    set_cmap("prism")
 
 
-# This function was autogenerated by boilerplate.py.  Do not edit as
-# changes will be lost
+# Autogenerated by boilerplate.py.  Do not edit as changes will be lost.
 def spring():
-    '''
-    set the default colormap to spring and apply to current image if any.
-    See help(colormaps) for more information
-    '''
-    rc('image', cmap='spring')
-    im = gci()
+    """
+    Set the colormap to "spring".
 
-    if im is not None:
-        im.set_cmap(cm.spring)
+    This changes the default colormap as well as the colormap of the current
+    image if there is one. See ``help(colormaps)`` for more information.
+    """
+    set_cmap("spring")
 
 
-# This function was autogenerated by boilerplate.py.  Do not edit as
-# changes will be lost
+# Autogenerated by boilerplate.py.  Do not edit as changes will be lost.
 def summer():
-    '''
-    set the default colormap to summer and apply to current image if any.
-    See help(colormaps) for more information
-    '''
-    rc('image', cmap='summer')
-    im = gci()
+    """
+    Set the colormap to "summer".
 
-    if im is not None:
-        im.set_cmap(cm.summer)
+    This changes the default colormap as well as the colormap of the current
+    image if there is one. See ``help(colormaps)`` for more information.
+    """
+    set_cmap("summer")
 
 
-# This function was autogenerated by boilerplate.py.  Do not edit as
-# changes will be lost
+# Autogenerated by boilerplate.py.  Do not edit as changes will be lost.
 def winter():
-    '''
-    set the default colormap to winter and apply to current image if any.
-    See help(colormaps) for more information
-    '''
-    rc('image', cmap='winter')
-    im = gci()
+    """
+    Set the colormap to "winter".
 
-    if im is not None:
-        im.set_cmap(cm.winter)
+    This changes the default colormap as well as the colormap of the current
+    image if there is one. See ``help(colormaps)`` for more information.
+    """
+    set_cmap("winter")
 
 
-# This function was autogenerated by boilerplate.py.  Do not edit as
-# changes will be lost
+# Autogenerated by boilerplate.py.  Do not edit as changes will be lost.
 def magma():
-    '''
-    set the default colormap to magma and apply to current image if any.
-    See help(colormaps) for more information
-    '''
-    rc('image', cmap='magma')
-    im = gci()
+    """
+    Set the colormap to "magma".
 
-    if im is not None:
-        im.set_cmap(cm.magma)
+    This changes the default colormap as well as the colormap of the current
+    image if there is one. See ``help(colormaps)`` for more information.
+    """
+    set_cmap("magma")
 
 
-# This function was autogenerated by boilerplate.py.  Do not edit as
-# changes will be lost
+# Autogenerated by boilerplate.py.  Do not edit as changes will be lost.
 def inferno():
-    '''
-    set the default colormap to inferno and apply to current image if any.
-    See help(colormaps) for more information
-    '''
-    rc('image', cmap='inferno')
-    im = gci()
+    """
+    Set the colormap to "inferno".
 
-    if im is not None:
-        im.set_cmap(cm.inferno)
+    This changes the default colormap as well as the colormap of the current
+    image if there is one. See ``help(colormaps)`` for more information.
+    """
+    set_cmap("inferno")
 
 
-# This function was autogenerated by boilerplate.py.  Do not edit as
-# changes will be lost
+# Autogenerated by boilerplate.py.  Do not edit as changes will be lost.
 def plasma():
-    '''
-    set the default colormap to plasma and apply to current image if any.
-    See help(colormaps) for more information
-    '''
-    rc('image', cmap='plasma')
-    im = gci()
+    """
+    Set the colormap to "plasma".
 
-    if im is not None:
-        im.set_cmap(cm.plasma)
+    This changes the default colormap as well as the colormap of the current
+    image if there is one. See ``help(colormaps)`` for more information.
+    """
+    set_cmap("plasma")
 
 
-# This function was autogenerated by boilerplate.py.  Do not edit as
-# changes will be lost
+# Autogenerated by boilerplate.py.  Do not edit as changes will be lost.
 def viridis():
-    '''
-    set the default colormap to viridis and apply to current image if any.
-    See help(colormaps) for more information
-    '''
-    rc('image', cmap='viridis')
-    im = gci()
+    """
+    Set the colormap to "viridis".
 
-    if im is not None:
-        im.set_cmap(cm.viridis)
+    This changes the default colormap as well as the colormap of the current
+    image if there is one. See ``help(colormaps)`` for more information.
+    """
+    set_cmap("viridis")
 
 
-# This function was autogenerated by boilerplate.py.  Do not edit as
-# changes will be lost
+# Autogenerated by boilerplate.py.  Do not edit as changes will be lost.
 def nipy_spectral():
-    '''
-    set the default colormap to nipy_spectral and apply to current image if any.
-    See help(colormaps) for more information
-    '''
-    rc('image', cmap='nipy_spectral')
-    im = gci()
+    """
+    Set the colormap to "nipy_spectral".
 
-    if im is not None:
-        im.set_cmap(cm.nipy_spectral)
+    This changes the default colormap as well as the colormap of the current
+    image if there is one. See ``help(colormaps)`` for more information.
+    """
+    set_cmap("nipy_spectral")
 
 
-# This function was autogenerated by boilerplate.py.  Do not edit as
-# changes will be lost
+# Autogenerated by boilerplate.py.  Do not edit as changes will be lost.
 def spectral():
-    '''
-    set the default colormap to spectral and apply to current image if any.
-    See help(colormaps) for more information
-    '''
+    """
+    Set the colormap to "spectral".
+
+    This changes the default colormap as well as the colormap of the current
+    image if there is one. See ``help(colormaps)`` for more information.
+    """
     from matplotlib.cbook import warn_deprecated
     warn_deprecated(
                     "2.0",
                     name="spectral",
                     obj_type="colormap"
                     )
-
-    rc('image', cmap='spectral')
-    im = gci()
-
-    if im is not None:
-        im.set_cmap(cm.spectral)
+    set_cmap("spectral")
 
 _setup_pyplot_info_docstrings()
diff --git a/tools/boilerplate.py b/tools/boilerplate.py
index 5c34b4f869f2..7b4ace55bd84 100644
--- a/tools/boilerplate.py
+++ b/tools/boilerplate.py
@@ -42,8 +42,7 @@
 
 
 AUTOGEN_MSG = """
-# This function was autogenerated by boilerplate.py.  Do not edit as
-# changes will be lost"""
+# Autogenerated by boilerplate.py.  Do not edit as changes will be lost."""
 
 
 PLOT_TEMPLATE = AUTOGEN_MSG + """
@@ -77,40 +76,35 @@ def %(func)s(%(argspec)s):
 """
 
 # Used for colormap functions
-CMAP_TEMPLATE = AUTOGEN_MSG + """
+CMAP_TEMPLATE = AUTOGEN_MSG + '''
 def {name}():
-    '''
-    set the default colormap to {name} and apply to current image if any.
-    See help(colormaps) for more information
-    '''
-    rc('image', cmap='{name}')
-    im = gci()
+    """
+    Set the colormap to "{name}".
 
-    if im is not None:
-        im.set_cmap(cm.{name})
+    This changes the default colormap as well as the colormap of the current
+    image if there is one. See ``help(colormaps)`` for more information.
+    """
+    set_cmap("{name}")
 
-"""
+'''
 
-CMAP_TEMPLATE_DEPRECATED = AUTOGEN_MSG + """
+CMAP_TEMPLATE_DEPRECATED = AUTOGEN_MSG + '''
 def {name}():
-    '''
-    set the default colormap to {name} and apply to current image if any.
-    See help(colormaps) for more information
-    '''
+    """
+    Set the colormap to "{name}".
+
+    This changes the default colormap as well as the colormap of the current
+    image if there is one. See ``help(colormaps)`` for more information.
+    """
     from matplotlib.cbook import warn_deprecated
     warn_deprecated(
                     "2.0",
                     name="{name}",
                     obj_type="colormap"
                     )
+    set_cmap("{name}")
 
-    rc('image', cmap='{name}')
-    im = gci()
-
-    if im is not None:
-        im.set_cmap(cm.{name})
-
-"""
+'''
 
 
 def boilerplate_gen():