def plot_gallery(saveplot=False):
    '''Make plot of colormaps and labels, like in the matplotlib
    gallery.

    :param saveplot=False: Whether to save the plot or not.

    '''

    from colorspacious import cspace_converter

    gradient = np.linspace(0, 1, 256)
    gradient = np.vstack((gradient, gradient))
    x = np.linspace(0.0, 1.0, 256)

    fig, axes = plt.subplots(nrows=int(len(cm.cmap_d)/2), ncols=1, figsize=(6, 12))
    fig.subplots_adjust(top=0.99, bottom=0.01, left=0.2, right=0.99, wspace=0.05)

    for ax, cmapname in zip(axes, cm.cmapnames):

        if '_r' in cmapname:  # skip reversed versions for plot
            continue

        cmap = cm.cmap_d[cmapname]  # get the colormap instance

        rgb = cmap(x)[np.newaxis, :, :3]

        # Find a good conversion to grayscale
        jch = cspace_converter("sRGB1", "CAM02-UCS")(rgb)  # Not sure why to use JCh instead so using this.
        L = jch[0, :, 0]
        L = np.float32(np.vstack((L, L, L)))

        ax.imshow(gradient, aspect='auto', cmap=cmap)

        pos1 = ax.get_position()  # get the original position
        pos2 = [pos1.x0, pos1.y0,  pos1.width, pos1.height / 3.0]
        axbw = fig.add_axes(pos2)  # colorbar axes
        axbw.set_axis_off()
        axbw.imshow(L, aspect='auto', cmap=cm.gray, vmin=0, vmax=100.)
        pos = list(ax.get_position().bounds)
        x_text = pos[0] - 0.01
        y_text = pos[1] + pos[3]/2.
        fig.text(x_text, y_text, cmap.name, va='center', ha='right')

    # Turn off *all* ticks & spines, not just the ones with colormaps.
    for ax in axes:
        ax.set_axis_off()

    if saveplot:
        fig.savefig('figures/gallery.pdf', bbox_inches='tight')
        fig.savefig('figures/gallery.png', bbox_inches='tight')

    plt.show()
Make plot of colormaps and labels, like in the matplotlib
    gallery.

    :param saveplot=False: Whether to save the plot or not.