Python matplotlib.cm.spectral() Examples

The following are code examples for showing how to use matplotlib.cm.spectral(). They are from open source Python projects. You can vote up the examples you like or vote down the ones you don't like.

Example 1
Project: LaserTOF   Author: kyleuckert   File: pyplot.py    MIT License 9 votes vote down vote up
def spectral():
    '''
    set the default colormap to spectral and apply to current image if any.
    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) 
Example 2
Project: Computable   Author: ktraunmueller   File: pyplot.py    MIT License 6 votes vote down vote up
def spectral():
    '''
    set the default colormap to spectral and apply to current image if any.
    See help(colormaps) for more information
    '''
    rc('image', cmap='spectral')
    im = gci()

    if im is not None:
        im.set_cmap(cm.spectral)
    draw_if_interactive() 
Example 3
Project: gpsdata   Author: kundor   File: plotter.py    GNU General Public License v3.0 6 votes vote down vote up
def colorplot(ax, X, Y, C, label=None, numlabs=4):
    """Plot data in array X vs. array Y with points colored by C (on axis ax)

    X, Y, and C must be arrays (or lists, tuples) and have the same length;
    C can be matplotlib character colors, names, hex strings, RGB tuples.
    If C is only 1d float values, it will be treated as a z-axis and mapped
    to the default colormap.
    label, if defined, is text to be periodically placed on the line.
    """
    # That means normalizing to 0-1 and using matplotlib.colors.Colormap
    if isinstance(C[0], (float, int)):
        nm = Normalize(min(C), max(C))
        C = cmap(nm(C))
    # TODO : keep nm for all instances, so all lines are colored equivalently
    for x, y, c, n in zip(X, Y, C, count()):
        ax.plot([x], [y], linestyle='', marker='.', ms=1., mfc=c)
        if label is not None and not n % (len(X)//numlabs):
            ax.annotate(label, [x, y]) 
Example 4
Project: neural-network-animation   Author: miloharper   File: pyplot.py    MIT License 6 votes vote down vote up
def spectral():
    '''
    set the default colormap to spectral and apply to current image if any.
    See help(colormaps) for more information
    '''
    rc('image', cmap='spectral')
    im = gci()

    if im is not None:
        im.set_cmap(cm.spectral)
    draw_if_interactive() 
Example 5
Project: Blackjack-Tracker   Author: martinabeleda   File: pyplot.py    MIT License 6 votes vote down vote up
def spectral():
    '''
    set the default colormap to spectral and apply to current image if any.
    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) 
Example 6
Project: transnet   Author: OpenGridMap   File: Plotter.py    Apache License 2.0 6 votes vote down vote up
def __init__(self, voltage_levels):
        cmap = cm.spectral
        self.color_dict = dict()
        self.thickness_dict = dict()
        self.zorder_dict = dict()
        self.root = logging.getLogger()
        self.root.info('Plotting Voltages %s' % str(voltage_levels))
        if voltage_levels:
            for voltage in voltage_levels.split('|'):
                self.color_dict[voltage] = cmap(int(255 * ((int(voltage) - 110000) / 340000.0)))
                if int(voltage) / 300000 > 0:
                    self.thickness_dict[voltage] = 1
                    self.zorder_dict[voltage] = 1
                elif int(voltage) / 220000 > 0:
                    self.thickness_dict[voltage] = 0.75
                    self.zorder_dict[voltage] = 2
                else:
                    self.thickness_dict[voltage] = 0.5
                    self.zorder_dict[voltage] = 3 
Example 7
Project: cnidaria   Author: sauloal   File: pyplot.py    MIT License 6 votes vote down vote up
def spectral():
    '''
    set the default colormap to spectral and apply to current image if any.
    See help(colormaps) for more information
    '''
    rc('image', cmap='spectral')
    im = gci()

    if im is not None:
        im.set_cmap(cm.spectral)
    draw_if_interactive()