Python matplotlib.cm.plasma() Examples

The following are 6 code examples of matplotlib.cm.plasma(). 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 also want to check out all available functions/classes of the module matplotlib.cm , or try the search function .
Example #1
Source File: logP_analysis2.py    From SAMPL6 with MIT License 5 votes vote down vote up
def create_molecular_error_distribution_plots(collection_df, directory_path, file_base_name, subset_of_method_ids):

    # Ridge plot using all predictions
    ridge_plot(df=collection_df, by = "Molecule ID", column = "$\Delta$logP error (calc - exp)", figsize=(4, 6),
                colormap=cm.plasma)
    plt.savefig(directory_path + "/" + file_base_name +"_all_methods.pdf")

    # Ridge plot using only consistently well-performing methods
    collection_subset_df =  collection_df[collection_df["receipt_id"].isin(subset_of_method_ids)].reset_index(drop=True)
    ridge_plot(df=collection_subset_df, by = "Molecule ID", column = "$\Delta$logP error (calc - exp)", figsize=(4, 6),
                colormap=cm.plasma)
    plt.savefig(directory_path + "/" + file_base_name +"_well_performing_methods.pdf") 
Example #2
Source File: logP_analysis2.py    From SAMPL6 with MIT License 5 votes vote down vote up
def create_category_error_distribution_plots(collection_df, directory_path, file_base_name):

    # Ridge plot using all predictions
    ridge_plot_wo_overlap(df=collection_df, by = "reassigned category", column = "$\Delta$logP error (calc - exp)", figsize=(4, 4),
                colormap=cm.plasma)
    plt.savefig(directory_path + "/" + file_base_name +".pdf") 
Example #3
Source File: logP_analysis2.py    From SAMPL6 with MIT License 5 votes vote down vote up
def create_molecular_error_distribution_plots(collection_df, directory_path, file_base_name):

    # Ridge plot using all predictions
    ridge_plot(df=collection_df, by = "Molecule ID", column = "$\Delta$logP error (calc - exp)", figsize=(4, 6),
                colormap=cm.plasma)
    plt.savefig(directory_path + "/" + file_base_name +"_all_methods.pdf")



# =============================================================================
# MAIN
# ============================================================================= 
Example #4
Source File: bird_vis.py    From cmr with MIT License 5 votes vote down vote up
def visflow(flow_img):
    # H x W x 2
    flow_img = convert2np(flow_img)
    from matplotlib import cm
    x_img = flow_img[:, :, 0]

    def color_within_01(vals):
        # vals is Nx1 in [-1, 1] (but could be larger)
        vals = np.clip(vals, -1, 1)
        # make [0, 1]
        vals = (vals + 1) / 2.
        # Append dummy end vals for consistent coloring
        weights = np.hstack([vals, np.array([0, 1])])
        # Drop the dummy colors
        colors = cm.plasma(weights)[:-2, :3]
        return colors

    # x_color = cm.plasma(x_img.reshape(-1))[:, :3]
    x_color = color_within_01(x_img.reshape(-1))
    x_color = x_color.reshape([x_img.shape[0], x_img.shape[1], 3])
    y_img = flow_img[:, :, 1]
    # y_color = cm.plasma(y_img.reshape(-1))[:, :3]
    y_color = color_within_01(y_img.reshape(-1))
    y_color = y_color.reshape([y_img.shape[0], y_img.shape[1], 3])
    vis = np.vstack([x_color, y_color])
    # import matplotlib.pyplot as plt
    # plt.ion()
    # plt.imshow(x_color)
    return vis 
Example #5
Source File: check_sim_stability.py    From gymfc with MIT License 4 votes vote down vote up
def process_results(self):
        """ Sync the results up accoding to the sim time and determine
        which rates are stable and instable in the sim 
        Returns Array or RPYs, Max rate that is stable, color for each RPY point, """
        threshold = 0.001 #1mm
        instable = []
        stable = []

        d_range = self.max_d_sum - self.min_d_sum
        print ("Min=", self.min_d_sum)
        print ("Max=", self.max_d_sum)
        print ("D range=", d_range)


        norm = matplotlib.colors.Normalize(vmin=self.min_d_sum, vmax=self.max_d_sum, clip=True)
        mapper = cm.ScalarMappable(norm=norm, cmap=cm.plasma)

        #print (self.data_pose)
        max_r = 0
        colors = []
        rates = []
        ds = [] #array of distance sums

        for i in range(len(self.data_pose)):

            ac_trial = np.array(self.data_ac[i])
            for pose in self.data_pose[i]:
                t = pose[0]
                d_sum = pose[1]
                found_row = ac_trial[np.where(ac_trial[:,0] == t)]
                if len(found_row) > 0:
                    rate = found_row[0][1:]
                    #print ("t=", t, " d_sum", d_sum)
                    #print (found_row)

                    colors.append(mapper.to_rgba(d_sum))
                    rates.append(rate)
                    ds.append(d_sum)

                    if d_sum >= threshold:
                        instable.append(rate)
                        if (rate < self.min_rate).all():
                            self.min_rate = rate.copy()
                    else:
                        stable.append(rate)
                        r = np.linalg.norm(rate)
                        if r > max_r:
                            max_r = r
            #print ("t=", t, " rpy=", rate)
        #return np.array(instable), np.array(stable), max_r, colors
        print ("Instability occurs at ", self.min_rate)
        np.savetxt("/tmp/unstable.txt", instable )
        return np.array(rates), max_r, colors, ds 
Example #6
Source File: check_sim_stability.py    From gymfc with MIT License 4 votes vote down vote up
def plot(self):

        #instable, stable, r, colors = self.process_results()
        rates, r, colors, ds = self.process_results()

        #print ("Instable", instable)
        #print ("Stable", stable)

        fig = plt.figure()
        ax = fig.add_subplot(111, projection='3d')

        #stable = ax.scatter(data[:,0], data[:,1], data[:,2], c=colors, label=labels)
        """
        if len(stable)>0:
            ax_stable = ax.scatter(stable[:,0], stable[:,1], stable[:,2], c='b')
        if len(instable)>0:
            ax_instable = ax.scatter(instable[:,0], instable[:,1], instable[:,2], c='r')
        """
        ax_instable = ax.scatter(rates[:,0], rates[:,1], rates[:,2], c=ds, cmap='plasma')

        steps = 20
        theta, phi = np.linspace(0, 2 * np.pi, steps), np.linspace(0, np.pi, steps)
        THETA, PHI = np.meshgrid(theta, phi)
        x = r * np.sin(PHI) * np.cos(THETA)
        y = r * np.sin(PHI) * np.sin(THETA)
        z = r * np.cos(PHI)
        #ax.plot_wireframe(x, y, z, color="b")


        ax.set_xlabel('Roll (deg/s)')
        ax.set_ylabel('Pitch (deg/s)')
        ax.set_zlabel('Yaw (deg/s)')

        """
        if len(instable)>0:
            print ("HERE")
            ax.legend((ax_stable, ax_instable), ("Stable Region", "Instable"))
        else:
            print ("HERE2")
            ax.legend((ax_stable,), ("Stable Region",))
        """
        title_mapping = {
            "dart" : "DART",
            "ode" : "ODE",
            "bullet" : "Bullet",
            "simbody" : "Simbody"
        }
        #plt.title("{} Physics Engine - Step size {}".format(title_mapping[self.physics_type], self.step_size))

        #_data = plt.cm.jet()

        cb = plt.colorbar(ax_instable, ax=ax)

        cb.set_label(label='Model Drift (meters)', weight='bold')
        plt.show()