Python matplotlib.cm.hsv() Examples

The following are 6 code examples for showing how to use matplotlib.cm.hsv(). These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.

You may want to check out the right sidebar which shows the related API usage.

You may also want to check out all available functions/classes of the module matplotlib.cm , or try the search function .

Example 1
Project: PythonPilot   Author: YanbaruRobotics   File: dbscan_based.py    License: Apache License 2.0 6 votes vote down vote up
def draw(self, dbscan_input_array, dbscan_label, dbscan_label_n):

        # convert array to image
        frame_draw = np.zeros((self.__compress_height, self.__compress_width), np.uint8)
        frame_draw = cv2.cvtColor(frame_draw, cv2.COLOR_GRAY2RGB)
        for i in range(dbscan_input_array.shape[0]):
            if not dbscan_label[i] == -1:
                color_th = dbscan_label[i] / dbscan_label_n
                c_r = int(cm.hsv(color_th)[0]*255)
                c_g = int(cm.hsv(color_th)[1]*255)
                c_b = int(cm.hsv(color_th)[2]*255)
                frame_draw = cv2.circle(frame_draw, \
                                        (int(dbscan_input_array[i][0]), \
                                         int(dbscan_input_array[i][1])), \
                                        1, (c_r, c_g, c_b), 1)

        return frame_draw 
Example 2
Project: Computable   Author: ktraunmueller   File: pyplot.py    License: MIT License 5 votes vote down vote up
def hsv():
    '''
    set the default colormap to hsv and apply to current image if any.
    See help(colormaps) for more information
    '''
    rc('image', cmap='hsv')
    im = gci()

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


# This function was autogenerated by boilerplate.py.  Do not edit as
# changes will be lost 
Example 3
Project: matplotlib-4-abaqus   Author: Solid-Mechanics   File: pyplot.py    License: MIT License 5 votes vote down vote up
def hsv():
    '''
    set the default colormap to hsv and apply to current image if any.
    See help(colormaps) for more information
    '''
    rc('image', cmap='hsv')
    im = gci()

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


# This function was autogenerated by boilerplate.py.  Do not edit as
# changes will be lost 
Example 4
Project: neural-network-animation   Author: miloharper   File: pyplot.py    License: MIT License 5 votes vote down vote up
def hsv():
    '''
    set the default colormap to hsv and apply to current image if any.
    See help(colormaps) for more information
    '''
    rc('image', cmap='hsv')
    im = gci()

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


# This function was autogenerated by boilerplate.py.  Do not edit as
# changes will be lost 
Example 5
Project: MLSS   Author: NICTA   File: tututils.py    License: GNU General Public License v2.0 5 votes vote down vote up
def plot_2d_clusters(X, labels, centers):
    """
    Given an observation array, a label vector, and the location of the centers
    plot the clusters
    """

    clabels = set(labels)
    K = len(clabels)

    if len(centers) != K:
        raise ValueError("Expecting the number of unique labels and centres to"
                         " be the same!")

    # Plot the true clusters
    figure(figsize=(10, 10))
    ax = gca()

    vor = Voronoi(centers)

    voronoi_plot_2d(vor, ax)

    colors = cm.hsv(np.arange(K)/float(K))
    for k, col in enumerate(colors):
        my_members = labels == k
        scatter(X[my_members, 0], X[my_members, 1], c=col, marker='o', s=20)

    for k, col in enumerate(colors):
        cluster_center = centers[k]
        scatter(cluster_center[0], cluster_center[1], c=col, marker='o', s=200)

    axis('tight')
    axis('equal')
    title('Clusters') 
Example 6
Project: MLSS   Author: NICTA   File: tututils.py    License: GNU General Public License v2.0 5 votes vote down vote up
def plot_2d_GMMs(X, labels, means, covs, percentcontour=0.66, npoints=30):
    """
    Given an observation array, a label vector (integer values), and GMM mean
    and covariance parameters, plot the clusters and parameters.
    """

    clabels = set(labels)
    K = len(clabels)

    if len(means) != len(covs) != K:
        raise ValueError("Expecting the number of unique labels, means and"
                         "covariances to be the same!")

    phi = np.linspace(-np.pi, np.pi, npoints)

    circle = np.array([np.sin(phi), np.cos(phi)]).T

    figure(figsize=(10, 10))
    gca()

    colors = cm.hsv(np.arange(K)/float(K))
    for k, col in zip(clabels, colors):

        # points
        my_members = labels == k
        scatter(X[my_members, 0], X[my_members, 1], c=col, marker='o', s=20)

        # means
        cluster_center = means[k, :]
        scatter(cluster_center[0], cluster_center[1], c=col, marker='o', s=200)

        # covariance
        L = la.cholesky(np.array(covs[k]) * chi2.ppf(percentcontour, [3])
                        + 1e-5 * np.eye(covs[k].shape[0]))
        covpoints = circle.dot(L) + means[k, :]
        plot(covpoints[:, 0], covpoints[:, 1], color=col, linewidth=3)

    axis('tight')
    axis('equal')
    title('Clusters')