scicm/tools.py
def crop(cmapin,vmin=0.0,vmax=1.0,name_newcmap=None):
    '''Crop colour map between vmin/vmax values. Can also register the new colour map with matplotlib.
    
    Parameters
    ----------
    cmapin : str or object
        A string with the name of the colour map or the colour map object.
    vmin/vmax : float, optional
        If given, the normalised low/high limits to select from the source colourmap. Values must
        be in the [0,1] range and vmin<vmax. Defaults to vmin=0 and vmax=1 (i.e., returns the
        input colourmap).
    name_newcmap : str, optional
        If given, defines the name to register with matplotlib.
    Returns
    -------
    newcmap
        Colourmap object with the new colour map.
    '''
    
    if vmin>vmax:
        raise ValueError('The value of vmin must be lower than vmax')
    if vmin<0.0 or vmax>1.0:
        raise ValueError('The values of vmin/vmax must be in the closed range [0,1]')
    if not isinstance(name_newcmap,str) and name_newcmap is not None:
        raise TypeError('name_newcmap must be a string')
    
    if isinstance(cmapin,str):
        cmapin=cm.get_cmap(cmapin)
    
    cmap_data=cmapin(np.linspace(vmin,vmax,256))
    
    if name_newcmap:
        newcmap=LSC.from_list(name_newcmap,cmap_data,N=cmap_data.shape[0])
        cm.register_cmap(name_newcmap,newcmap)
    else:
        newcmap=LSC.from_list('newcmap',cmap_data,N=cmap_data.shape[0])
    
    return newcmap
Crop colour map between vmin/vmax values. Can also register the new colour map with matplotlib.
    
    Parameters
    ----------
    cmapin : str or object
        A string with the name of the colour map or the colour map object.
    vmin/vmax : float, optional
        If given, the normalised low/high limits to select from the source colourmap. Values must
        be in the [0,1] range and vmin<vmax. Defaults to vmin=0 and vmax=1 (i.e., returns the
        input colourmap).
    name_newcmap : str, optional
        If given, defines the name to register with matplotlib.
    Returns
    -------
    newcmap
        Colourmap object with the new colour map.
    
Crop colour map between vmin/vmax values. Can also register the new colour map with matplotlib.
Parameters

cmapin : str or object
A string with the name of the colour map or the colour map object.
vmin/vmax : float, optional
If given, the normalised low/high limits to select from the source colourmap. Values must
be in the [0,1] range and vmin<vmax. Defaults to vmin=0 and vmax=1 .
name_newcmap : str, optional
If given, defines the name to register with matplotlib.
Returns

newcmap
Colourmap object with the new colour map.
Crop colour map between vmin / vmax values . Can also register the new colour map with matplotlib . Parameters cmapin : str or object A string with the name of the colour map or the colour map object . vmin / vmax : float optional If given the normalised low / high limits to select from the source colourmap . Values must be in the [ 0 1 ] range and vmin<vmax . Defaults to vmin = 0 and vmax = 1 . name_newcmap : str optional If given defines the name to register with matplotlib . Returns newcmap Colourmap object with the new colour map .
def crop(cmapin,vmin=0.0,vmax=1.0,name_newcmap=None):
    if vmin>vmax:
        raise ValueError('The value of vmin must be lower than vmax')
    if vmin<0.0 or vmax>1.0:
        raise ValueError('The values of vmin/vmax must be in the closed range [0,1]')
    if not isinstance(name_newcmap,str) and name_newcmap is not None:
        raise TypeError('name_newcmap must be a string')
    if isinstance(cmapin,str):
        cmapin=cm.get_cmap(cmapin)
    cmap_data=cmapin(np.linspace(vmin,vmax,256))
    if name_newcmap:
        newcmap=LSC.from_list(name_newcmap,cmap_data,N=cmap_data.shape[0])
        cm.register_cmap(name_newcmap,newcmap)
    else:
        newcmap=LSC.from_list('newcmap',cmap_data,N=cmap_data.shape[0])
    return newcmap
def crop ( cmapin , vmin = 0.0 , vmax = 1.0 , name_newcmap = None ) : if vmin > vmax : raise ValueError ( 'The value of vmin must be lower than vmax' ) if vmin < 0.0 or vmax > 1.0 : raise ValueError ( 'The values of vmin/vmax must be in the closed range [0,1]' ) if not isinstance ( name_newcmap , str ) and name_newcmap is not None : raise TypeError ( 'name_newcmap must be a string' ) if isinstance ( cmapin , str ) : cmapin = cm . get_cmap ( cmapin ) cmap_data = cmapin ( np . linspace ( vmin , vmax , 256 ) ) if name_newcmap : newcmap = LSC . from_list ( name_newcmap , cmap_data , N = cmap_data . shape [ 0 ] ) cm . register_cmap ( name_newcmap , newcmap ) else : newcmap = LSC . from_list ( 'newcmap' , cmap_data , N = cmap_data . shape [ 0 ] ) return newcmap
Crop colour map between vmin/vmax values.
Crop colour map between vmin / vmax values .
'''Crop colour map between vmin/vmax values. Can also register the new colour map with matplotlib.
    
    Parameters
    ----------
    cmapin : str or object
        A string with the name of the colour map or the colour map object.
    vmin/vmax : float, optional
        If given, the normalised low/high limits to select from the source colourmap. Values must
        be in the [0,1] range and vmin<vmax. Defaults to vmin=0 and vmax=1 (i.e., returns the
        input colourmap).
    name_newcmap : str, optional
        If given, defines the name to register with matplotlib.
    Returns
    -------
    newcmap
        Colourmap object with the new colour map.
    '''
cmapin
vmin
vmax
name_newcmap