sidpy/viz/plot_utils/curve.py
def rainbow_plot(axis, x_vec, y_vec, num_steps=32, **kwargs):
    """
    Plots the input against the output vector such that the color of the curve changes as a function of index

    Parameters
    ----------
    axis : matplotlib.axes.Axes object
        Axis to plot the curve
    x_vec : 1D float numpy array
        vector that forms the X axis
    y_vec : 1D float numpy array
        vector that forms the Y axis
    num_steps : unsigned int (Optional)
        Number of discrete color steps
    """
    if not isinstance(axis, mpl.axes.Axes):
        raise TypeError('axis must be a matplotlib.axes.Axes object')
    if not isinstance(x_vec, (list, tuple, np.ndarray, da.core.Array)):
        raise TypeError('x_vec must be array-like of numbers')
    if not isinstance(x_vec, (list, tuple, np.ndarray, da.core.Array)):
        raise TypeError('x_vec must be array-like of numbers')
    x_vec = np.array(x_vec)
    y_vec = np.array(y_vec)
    assert x_vec.ndim == 1 and y_vec.ndim == 1, 'x_vec and y_vec must be 1D arrays'
    assert x_vec.shape == y_vec.shape, 'x_vec and y_vec must have the same shape'

    if not isinstance(num_steps, int):
        raise TypeError('num_steps must be an integer < size of x_vec')
    if num_steps < 2 or num_steps >= len(x_vec) // 2:
        raise ValueError('num_steps should be a positive number. 1/4 to 1/16th of x_vec')
    assert num_steps < x_vec.size, 'num_steps must be an integer < size of x_vec'

    assert isinstance(kwargs, dict)
    cmap = kwargs.pop('cmap', default_cmap)
    cmap = get_cmap_object(cmap)

    # Remove any color flag
    _ = kwargs.pop('color', None)

    pts_per_step = len(y_vec) // num_steps

    for step in range(num_steps - 1):
        axis.plot(x_vec[step * pts_per_step:(step + 1) * pts_per_step],
                  y_vec[step * pts_per_step:(step + 1) * pts_per_step],
                  color=cmap(255 * step // num_steps), **kwargs)
    # plot the remainder:
    axis.plot(x_vec[(num_steps - 1) * pts_per_step:],
              y_vec[(num_steps - 1) * pts_per_step:],
              color=cmap(255 * num_steps / num_steps), **kwargs)

    Plots the input against the output vector such that the color of the curve changes as a function of index

    Parameters
    ----------
    axis : matplotlib.axes.Axes object
        Axis to plot the curve
    x_vec : 1D float numpy array
        vector that forms the X axis
    y_vec : 1D float numpy array
        vector that forms the Y axis
    num_steps : unsigned int (Optional)
        Number of discrete color steps
    
Plots the input against the output vector such that the color of the curve changes as a function of index
Parameters

axis : matplotlib.axes.Axes object
Axis to plot the curve
x_vec : 1D float numpy array
vector that forms the X axis
y_vec : 1D float numpy array
vector that forms the Y axis
num_steps : unsigned int (Optional)
Number of discrete color steps
Plots the input against the output vector such that the color of the curve changes as a function of index Parameters axis : matplotlib . axes . Axes object Axis to plot the curve x_vec : 1D float numpy array vector that forms the X axis y_vec : 1D float numpy array vector that forms the Y axis num_steps : unsigned int ( Optional ) Number of discrete color steps
def rainbow_plot(axis, x_vec, y_vec, num_steps=32, **kwargs):
    if not isinstance(axis, mpl.axes.Axes):
        raise TypeError('axis must be a matplotlib.axes.Axes object')
    if not isinstance(x_vec, (list, tuple, np.ndarray, da.core.Array)):
        raise TypeError('x_vec must be array-like of numbers')
    if not isinstance(x_vec, (list, tuple, np.ndarray, da.core.Array)):
        raise TypeError('x_vec must be array-like of numbers')
    x_vec = np.array(x_vec)
    y_vec = np.array(y_vec)
    assert x_vec.ndim == 1 and y_vec.ndim == 1, 'x_vec and y_vec must be 1D arrays'
    assert x_vec.shape == y_vec.shape, 'x_vec and y_vec must have the same shape'
    if not isinstance(num_steps, int):
        raise TypeError('num_steps must be an integer < size of x_vec')
    if num_steps < 2 or num_steps >= len(x_vec) // 2:
        raise ValueError('num_steps should be a positive number. 1/4 to 1/16th of x_vec')
    assert num_steps < x_vec.size, 'num_steps must be an integer < size of x_vec'
    assert isinstance(kwargs, dict)
    cmap = kwargs.pop('cmap', default_cmap)
    cmap = get_cmap_object(cmap)
    _ = kwargs.pop('color', None)
    pts_per_step = len(y_vec) // num_steps
    for step in range(num_steps - 1):
        axis.plot(x_vec[step * pts_per_step:(step + 1) * pts_per_step],
                  y_vec[step * pts_per_step:(step + 1) * pts_per_step],
                  color=cmap(255 * step // num_steps), **kwargs)
    axis.plot(x_vec[(num_steps - 1) * pts_per_step:],
              y_vec[(num_steps - 1) * pts_per_step:],
              color=cmap(255 * num_steps / num_steps), **kwargs)
def rainbow_plot ( axis , x_vec , y_vec , num_steps = 32 , ** kwargs ) : if not isinstance ( axis , mpl . axes . Axes ) : raise TypeError ( 'axis must be a matplotlib.axes.Axes object' ) if not isinstance ( x_vec , ( list , tuple , np . ndarray , da . core . Array ) ) : raise TypeError ( 'x_vec must be array-like of numbers' ) if not isinstance ( x_vec , ( list , tuple , np . ndarray , da . core . Array ) ) : raise TypeError ( 'x_vec must be array-like of numbers' ) x_vec = np . array ( x_vec ) y_vec = np . array ( y_vec ) assert x_vec . ndim == 1 and y_vec . ndim == 1 , 'x_vec and y_vec must be 1D arrays' assert x_vec . shape == y_vec . shape , 'x_vec and y_vec must have the same shape' if not isinstance ( num_steps , int ) : raise TypeError ( 'num_steps must be an integer < size of x_vec' ) if num_steps < 2 or num_steps >= len ( x_vec ) // 2 : raise ValueError ( 'num_steps should be a positive number. 1/4 to 1/16th of x_vec' ) assert num_steps < x_vec . size , 'num_steps must be an integer < size of x_vec' assert isinstance ( kwargs , dict ) cmap = kwargs . pop ( 'cmap' , default_cmap ) cmap = get_cmap_object ( cmap ) _ = kwargs . pop ( 'color' , None ) pts_per_step = len ( y_vec ) // num_steps for step in range ( num_steps - 1 ) : axis . plot ( x_vec [ step * pts_per_step : ( step + 1 ) * pts_per_step ] , y_vec [ step * pts_per_step : ( step + 1 ) * pts_per_step ] , color = cmap ( 255 * step // num_steps ) , ** kwargs ) axis . plot ( x_vec [ ( num_steps - 1 ) * pts_per_step : ] , y_vec [ ( num_steps - 1 ) * pts_per_step : ] , color = cmap ( 255 * num_steps / num_steps ) , ** kwargs )
Plots the input against the output vector such that the color of the curve changes as a function of index
Parameters
Plots the input against the output vector such that the color of the curve changes as a function of index Parameters
"""
    Plots the input against the output vector such that the color of the curve changes as a function of index

    Parameters
    ----------
    axis : matplotlib.axes.Axes object
        Axis to plot the curve
    x_vec : 1D float numpy array
        vector that forms the X axis
    y_vec : 1D float numpy array
        vector that forms the Y axis
    num_steps : unsigned int (Optional)
        Number of discrete color steps
    """ # Remove any color flag # plot the remainder:
axis
x_vec
y_vec
num_steps