src/pys5p/tol_colors.py
def main():
    """
    Show all available colormaps and colorsets
    """
    # Change default colorset (for lines) and colormap (for maps).
#    plt.rc('axes', prop_cycle=plt.cycler('color', list(tol_cset('bright'))))
#    plt.cm.register_cmap('rainbow_PuRd', tol_cmap('rainbow_PuRd'))
#    plt.rc('image', cmap='rainbow_PuRd')

    # Show colorsets tol_cset(<scheme>).
    schemes = tol_cset()
    fig, axes = plt.subplots(ncols=len(schemes))
    fig.subplots_adjust(top=0.92, bottom=0.02, left=0.0, right=0.91)
    for ax, scheme in zip(axes, schemes):
        cset = tol_cset(scheme)
        names = cset._fields
        colors = list(cset)
        for name, color in zip(names, colors):
            ax.scatter([], [], c=color, s=80, label=name)
        ax.set_axis_off()
        ax.legend(loc=2)
        ax.set_title(scheme)
    plt.show()

    # Show colormaps tol_cmap(<scheme>).
    schemes = tol_cmap()
    gradient = np.linspace(0, 1, 256)
    gradient = np.vstack((gradient, gradient))
    fig, axes = plt.subplots(nrows=len(schemes))
    fig.subplots_adjust(top=0.98, bottom=0.02, left=0.29, right=0.99)
    for ax, scheme in zip(axes, schemes):
        pos = list(ax.get_position().bounds)
        ax.set_axis_off()
        ax.imshow(gradient, aspect=4, cmap=tol_cmap(scheme))
        fig.text(pos[0] - 0.01, pos[1] + pos[3]/2.,
                 scheme, va='center', ha='right', fontsize=10)
    plt.show()

    # Show colormaps tol_cmap('rainbow_discrete', <lut>).
    gradient = np.linspace(0, 1, 256)
    gradient = np.vstack((gradient, gradient))
    fig, axes = plt.subplots(nrows=23)
    fig.subplots_adjust(top=0.98, bottom=0.02, left=0.25, right=0.99)
    for lut, ax in enumerate(axes, start=1):
        pos = list(ax.get_position().bounds)
        ax.set_axis_off()
        ax.imshow(gradient, aspect=4, cmap=tol_cmap('rainbow_discrete', lut))
        fig.text(pos[0] - 0.01, pos[1] + pos[3]/2.,
                 'rainbow_discrete, ' + str(lut),
                 va='center', ha='right', fontsize=10)
    plt.show()

    Show all available colormaps and colorsets
    
Show all available colormaps and colorsets
Show all available colormaps and colorsets
def main():
    schemes = tol_cset()
    fig, axes = plt.subplots(ncols=len(schemes))
    fig.subplots_adjust(top=0.92, bottom=0.02, left=0.0, right=0.91)
    for ax, scheme in zip(axes, schemes):
        cset = tol_cset(scheme)
        names = cset._fields
        colors = list(cset)
        for name, color in zip(names, colors):
            ax.scatter([], [], c=color, s=80, label=name)
        ax.set_axis_off()
        ax.legend(loc=2)
        ax.set_title(scheme)
    plt.show()
    schemes = tol_cmap()
    gradient = np.linspace(0, 1, 256)
    gradient = np.vstack((gradient, gradient))
    fig, axes = plt.subplots(nrows=len(schemes))
    fig.subplots_adjust(top=0.98, bottom=0.02, left=0.29, right=0.99)
    for ax, scheme in zip(axes, schemes):
        pos = list(ax.get_position().bounds)
        ax.set_axis_off()
        ax.imshow(gradient, aspect=4, cmap=tol_cmap(scheme))
        fig.text(pos[0] - 0.01, pos[1] + pos[3]/2.,
                 scheme, va='center', ha='right', fontsize=10)
    plt.show()
    gradient = np.linspace(0, 1, 256)
    gradient = np.vstack((gradient, gradient))
    fig, axes = plt.subplots(nrows=23)
    fig.subplots_adjust(top=0.98, bottom=0.02, left=0.25, right=0.99)
    for lut, ax in enumerate(axes, start=1):
        pos = list(ax.get_position().bounds)
        ax.set_axis_off()
        ax.imshow(gradient, aspect=4, cmap=tol_cmap('rainbow_discrete', lut))
        fig.text(pos[0] - 0.01, pos[1] + pos[3]/2.,
                 'rainbow_discrete, ' + str(lut),
                 va='center', ha='right', fontsize=10)
    plt.show()
def main ( ) : schemes = tol_cset ( ) fig , axes = plt . subplots ( ncols = len ( schemes ) ) fig . subplots_adjust ( top = 0.92 , bottom = 0.02 , left = 0.0 , right = 0.91 ) for ax , scheme in zip ( axes , schemes ) : cset = tol_cset ( scheme ) names = cset . _fields colors = list ( cset ) for name , color in zip ( names , colors ) : ax . scatter ( [ ] , [ ] , c = color , s = 80 , label = name ) ax . set_axis_off ( ) ax . legend ( loc = 2 ) ax . set_title ( scheme ) plt . show ( ) schemes = tol_cmap ( ) gradient = np . linspace ( 0 , 1 , 256 ) gradient = np . vstack ( ( gradient , gradient ) ) fig , axes = plt . subplots ( nrows = len ( schemes ) ) fig . subplots_adjust ( top = 0.98 , bottom = 0.02 , left = 0.29 , right = 0.99 ) for ax , scheme in zip ( axes , schemes ) : pos = list ( ax . get_position ( ) . bounds ) ax . set_axis_off ( ) ax . imshow ( gradient , aspect = 4 , cmap = tol_cmap ( scheme ) ) fig . text ( pos [ 0 ] - 0.01 , pos [ 1 ] + pos [ 3 ] / 2. , scheme , va = 'center' , ha = 'right' , fontsize = 10 ) plt . show ( ) gradient = np . linspace ( 0 , 1 , 256 ) gradient = np . vstack ( ( gradient , gradient ) ) fig , axes = plt . subplots ( nrows = 23 ) fig . subplots_adjust ( top = 0.98 , bottom = 0.02 , left = 0.25 , right = 0.99 ) for lut , ax in enumerate ( axes , start = 1 ) : pos = list ( ax . get_position ( ) . bounds ) ax . set_axis_off ( ) ax . imshow ( gradient , aspect = 4 , cmap = tol_cmap ( 'rainbow_discrete' , lut ) ) fig . text ( pos [ 0 ] - 0.01 , pos [ 1 ] + pos [ 3 ] / 2. , 'rainbow_discrete, ' + str ( lut ) , va = 'center' , ha = 'right' , fontsize = 10 ) plt . show ( )
Show all available colormaps and colorsets
Show all available colormaps and colorsets
"""
    Show all available colormaps and colorsets
    """ # Change default colorset (for lines) and colormap (for maps). #    plt.rc('axes', prop_cycle=plt.cycler('color', list(tol_cset('bright')))) #    plt.cm.register_cmap('rainbow_PuRd', tol_cmap('rainbow_PuRd')) #    plt.rc('image', cmap='rainbow_PuRd') # Show colorsets tol_cset(<scheme>). # Show colormaps tol_cmap(<scheme>). # Show colormaps tol_cmap('rainbow_discrete', <lut>).