Python matplotlib.cm.jet() Examples

The following are 30 code examples for showing how to use matplotlib.cm.jet(). 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: Attention-Gated-Networks   Author: ozan-oktay   File: visualise_att_maps_epoch.py    License: MIT License 6 votes vote down vote up
def plotNNFilter(units, figure_id, interp='bilinear', colormap=cm.jet, colormap_lim=None):
    plt.ion()
    filters = units.shape[2]
    n_columns = round(math.sqrt(filters))
    n_rows = math.ceil(filters / n_columns) + 1
    fig = plt.figure(figure_id, figsize=(n_rows*3,n_columns*3))
    fig.clf()

    for i in range(filters):
        ax1 = plt.subplot(n_rows, n_columns, i+1)
        plt.imshow(units[:,:,i].T, interpolation=interp, cmap=colormap)
        plt.axis('on')
        ax1.set_xticklabels([])
        ax1.set_yticklabels([])
        plt.colorbar()
        if colormap_lim:
            plt.clim(colormap_lim[0],colormap_lim[1])

    plt.subplots_adjust(wspace=0, hspace=0)
    plt.tight_layout()

# Epochs 
Example 2
Project: Attention-Gated-Networks   Author: ozan-oktay   File: visualise_fmaps.py    License: MIT License 6 votes vote down vote up
def plotNNFilter(units, figure_id, interp='bilinear', colormap=cm.jet, colormap_lim=None):
    plt.ion()
    filters = units.shape[2]
    n_columns = round(math.sqrt(filters))
    n_rows = math.ceil(filters / n_columns) + 1
    fig = plt.figure(figure_id, figsize=(n_rows*3,n_columns*3))
    fig.clf()

    for i in range(filters):
        ax1 = plt.subplot(n_rows, n_columns, i+1)
        plt.imshow(units[:,:,i].T, interpolation=interp, cmap=colormap)
        plt.axis('on')
        ax1.set_xticklabels([])
        ax1.set_yticklabels([])
        plt.colorbar()
        if colormap_lim:
            plt.clim(colormap_lim[0],colormap_lim[1])

    plt.subplots_adjust(wspace=0, hspace=0)
    plt.tight_layout()

# Load options 
Example 3
Project: Attention-Gated-Networks   Author: ozan-oktay   File: visualise_attention.py    License: MIT License 6 votes vote down vote up
def plotNNFilter(units, figure_id, interp='bilinear', colormap=cm.jet, colormap_lim=None, title=''):
    plt.ion()
    filters = units.shape[2]
    n_columns = round(math.sqrt(filters))
    n_rows = math.ceil(filters / n_columns) + 1
    fig = plt.figure(figure_id, figsize=(n_rows*3,n_columns*3))
    fig.clf()

    for i in range(filters):
        ax1 = plt.subplot(n_rows, n_columns, i+1)
        plt.imshow(units[:,:,i].T, interpolation=interp, cmap=colormap)
        plt.axis('on')
        ax1.set_xticklabels([])
        ax1.set_yticklabels([])
        plt.colorbar()
        if colormap_lim:
            plt.clim(colormap_lim[0],colormap_lim[1])

    plt.subplots_adjust(wspace=0, hspace=0)
    plt.tight_layout()
    plt.suptitle(title) 
Example 4
Project: Attention-Gated-Networks   Author: ozan-oktay   File: visualise_attention.py    License: MIT License 6 votes vote down vote up
def plotNNFilterOverlay(input_im, units, figure_id, interp='bilinear',
                        colormap=cm.jet, colormap_lim=None, title='', alpha=0.8):
    plt.ion()
    filters = units.shape[2]
    fig = plt.figure(figure_id, figsize=(5,5))
    fig.clf()

    for i in range(filters):
        plt.imshow(input_im[:,:,0], interpolation=interp, cmap='gray')
        plt.imshow(units[:,:,i], interpolation=interp, cmap=colormap, alpha=alpha)
        plt.axis('off')
        plt.colorbar()
        plt.title(title, fontsize='small')
        if colormap_lim:
            plt.clim(colormap_lim[0],colormap_lim[1])

    plt.subplots_adjust(wspace=0, hspace=0)
    plt.tight_layout()

    # plt.savefig('{}/{}.png'.format(dir_name,time.time()))




## Load options 
Example 5
Project: recruit   Author: Frank-qlu   File: test_frame.py    License: Apache License 2.0 6 votes vote down vote up
def test_kde_colors(self):
        _skip_if_no_scipy_gaussian_kde()

        from matplotlib import cm

        custom_colors = 'rgcby'
        df = DataFrame(rand(5, 5))

        ax = df.plot.kde(color=custom_colors)
        self._check_colors(ax.get_lines(), linecolors=custom_colors)
        tm.close()

        ax = df.plot.kde(colormap='jet')
        rgba_colors = lmap(cm.jet, np.linspace(0, 1, len(df)))
        self._check_colors(ax.get_lines(), linecolors=rgba_colors)
        tm.close()

        ax = df.plot.kde(colormap=cm.jet)
        rgba_colors = lmap(cm.jet, np.linspace(0, 1, len(df)))
        self._check_colors(ax.get_lines(), linecolors=rgba_colors) 
Example 6
Project: psst   Author: power-system-simulation-toolbox   File: plot.py    License: MIT License 6 votes vote down vote up
def plot_stacked_power_generation(results, ax=None, kind='bar', legend=False):
    if ax is None:
        fig, axs = plt.subplots(1, 1, figsize=(16, 10))
        ax = axs

    df = results.power_generated
    cols = (df - results.unit_commitment*results.maximum_power_output).std().sort_values().index
    df = df[[c for c in cols]]

    df.plot(kind=kind, stacked=True, ax=ax, colormap=cm.jet, alpha=0.5, legend=legend)

    df = results.unit_commitment * results.maximum_power_output

    df = df[[c for c in cols]]

    df.plot.area(stacked=True, ax=ax, alpha=0.125/2,  colormap=cm.jet, legend=None)

    ax.set_ylabel('Dispatch and Committed Capacity (MW)')
    ax.set_xlabel('Time (h)')
    return ax 
Example 7
Project: ocelot   Author: ocelot-collab   File: emitt_spread.py    License: GNU General Public License v3.0 6 votes vote down vote up
def plot3D_data(data, x, y):
    X,Y = meshgrid(x,y)
    fig = plt.figure()
    ax = Axes3D(fig)
    #ax = fig.add_subplot(111, projection = "3d")
    ax.plot_surface(X, Y, data, rstride=1, cstride=1, cmap=cm.jet)

#def conditions_emitt_spread(screen):
#    if screen.ne ==1 and (screen.nx and screen.ny):
#        effect = 1
#    elif screen.ne ==1 and (screen.nx==1 and screen.ny):
#        effect = 2
#    elif screen.ne ==1 and (screen.nx and screen.ny == 1):
#        effect = 3
#    elif screen.ne >1 and (screen.nx == 1 and screen.ny == 1):
#        effect = 4
#    else:
#        effect = 0
#    return effect 
Example 8
Project: vnpy_crypto   Author: birforce   File: test_frame.py    License: MIT License 6 votes vote down vote up
def test_kde_colors(self):
        _skip_if_no_scipy_gaussian_kde()
        if not self.mpl_ge_1_5_0:
            pytest.skip("mpl is not supported")

        from matplotlib import cm

        custom_colors = 'rgcby'
        df = DataFrame(rand(5, 5))

        ax = df.plot.kde(color=custom_colors)
        self._check_colors(ax.get_lines(), linecolors=custom_colors)
        tm.close()

        ax = df.plot.kde(colormap='jet')
        rgba_colors = lmap(cm.jet, np.linspace(0, 1, len(df)))
        self._check_colors(ax.get_lines(), linecolors=rgba_colors)
        tm.close()

        ax = df.plot.kde(colormap=cm.jet)
        rgba_colors = lmap(cm.jet, np.linspace(0, 1, len(df)))
        self._check_colors(ax.get_lines(), linecolors=rgba_colors) 
Example 9
def plot4():
    # Density 1
    Z = gen_gaussian_plot_vals(x_hat, Σ)
    cs1 = ax.contour(X, Y, Z, 6, colors="black")
    ax.clabel(cs1, inline=1, fontsize=10)
    # Density 2
    M = Σ * G.T * linalg.inv(G * Σ * G.T + R)
    x_hat_F = x_hat + M * (y - G * x_hat)
    Σ_F = Σ - M * G * Σ
    Z_F = gen_gaussian_plot_vals(x_hat_F, Σ_F)
    cs2 = ax.contour(X, Y, Z_F, 6, colors="black")
    ax.clabel(cs2, inline=1, fontsize=10)
    # Density 3
    new_x_hat = A * x_hat_F
    new_Σ = A * Σ_F * A.T + Q
    new_Z = gen_gaussian_plot_vals(new_x_hat, new_Σ)
    cs3 = ax.contour(X, Y, new_Z, 6, colors="black")
    ax.clabel(cs3, inline=1, fontsize=10)
    ax.contourf(X, Y, new_Z, 6, alpha=0.6, cmap=cm.jet)
    ax.text(float(y[0]), float(y[1]), r"$y$", fontsize=20, color="black")

# == Choose a plot to generate == # 
Example 10
Project: python3_ios   Author: holzschu   File: logos2.py    License: BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def add_polar_bar():
    ax = fig.add_axes([0.025, 0.075, 0.2, 0.85], projection='polar')

    ax.patch.set_alpha(axalpha)
    ax.set_axisbelow(True)
    N = 7
    arc = 2. * np.pi
    theta = np.arange(0.0, arc, arc/N)
    radii = 10 * np.array([0.2, 0.6, 0.8, 0.7, 0.4, 0.5, 0.8])
    width = np.pi / 4 * np.array([0.4, 0.4, 0.6, 0.8, 0.2, 0.5, 0.3])
    bars = ax.bar(theta, radii, width=width, bottom=0.0)
    for r, bar in zip(radii, bars):
        bar.set_facecolor(cm.jet(r/10.))
        bar.set_alpha(0.6)

    ax.tick_params(labelbottom=False, labeltop=False,
                   labelleft=False, labelright=False)

    ax.grid(lw=0.8, alpha=0.9, ls='-', color='0.5')

    ax.set_yticks(np.arange(1, 9, 2))
    ax.set_rmax(9) 
Example 11
def test_kde_colors(self):
        _skip_if_no_scipy_gaussian_kde()

        from matplotlib import cm

        custom_colors = 'rgcby'
        df = DataFrame(rand(5, 5))

        ax = df.plot.kde(color=custom_colors)
        self._check_colors(ax.get_lines(), linecolors=custom_colors)
        tm.close()

        ax = df.plot.kde(colormap='jet')
        rgba_colors = lmap(cm.jet, np.linspace(0, 1, len(df)))
        self._check_colors(ax.get_lines(), linecolors=rgba_colors)
        tm.close()

        ax = df.plot.kde(colormap=cm.jet)
        rgba_colors = lmap(cm.jet, np.linspace(0, 1, len(df)))
        self._check_colors(ax.get_lines(), linecolors=rgba_colors) 
Example 12
Project: Context-Aware_Crowd_Counting-pytorch   Author: CommissarMa   File: test.py    License: MIT License 6 votes vote down vote up
def estimate_density_map(img_root,gt_dmap_root,model_param_path,index):
    '''
    Show one estimated density-map.
    img_root: the root of test image data.
    gt_dmap_root: the root of test ground truth density-map data.
    model_param_path: the path of specific mcnn parameters.
    index: the order of the test image in test dataset.
    '''
    device=torch.device("cuda")
    model=CANNet().to(device)
    model.load_state_dict(torch.load(model_param_path))
    dataset=CrowdDataset(img_root,gt_dmap_root,8,phase='test')
    dataloader=torch.utils.data.DataLoader(dataset,batch_size=1,shuffle=False)
    model.eval()
    for i,(img,gt_dmap) in enumerate(dataloader):
        if i==index:
            img=img.to(device)
            gt_dmap=gt_dmap.to(device)
            # forward propagation
            et_dmap=model(img).detach()
            et_dmap=et_dmap.squeeze(0).squeeze(0).cpu().numpy()
            print(et_dmap.shape)
            plt.imshow(et_dmap,cmap=CM.jet)
            break 
Example 13
Project: tf-matplotlib   Author: cheind   File: sgd.py    License: MIT License 6 votes vote down vote up
def init_fig(*args, **kwargs):
            '''Initialize figures.'''
            fig = tfmpl.create_figure(figsize=(8,6))
            ax = fig.add_subplot(111, projection='3d', elev=50, azim=-30)
            ax.w_xaxis.set_pane_color((1.0,1.0,1.0,1.0))
            ax.w_yaxis.set_pane_color((1.0,1.0,1.0,1.0))
            ax.w_zaxis.set_pane_color((1.0,1.0,1.0,1.0))
            ax.set_title('Gradient descent on Beale surface')
            ax.set_xlabel('$x$')
            ax.set_ylabel('$y$')
            ax.set_zlabel('beale($x$,$y$)')
        
            xx, yy = np.meshgrid(np.linspace(-4.5, 4.5, 40), np.linspace(-4.5, 4.5, 40))
            zz = beale(xx, yy)
            ax.plot_surface(xx, yy, zz, norm=LogNorm(), rstride=1, cstride=1, edgecolor='none', alpha=.8, cmap=cm.jet)
            ax.plot([3], [.5], [beale(3, .5)], 'k*', markersize=5)
            
            for o in optimizers:
                path, = ax.plot([],[],[], label=o[1])
                paths.append(path)

            ax.legend(loc='upper left')
            fig.tight_layout()

            return fig, paths 
Example 14
Project: fenics-topopt   Author: zfergus   File: stress_gui.py    License: MIT License 5 votes vote down vote up
def __init__(self, nelx, nely, stress_calculator, nu, title=""):
        """Initialize plot and plot the initial design"""
        super(StressGUI, self).__init__(nelx, nely, title)
        self.stress_im = self.ax.imshow(
            np.swapaxes(np.zeros((nelx, nely, 4)), 0, 1),
            norm=colors.Normalize(vmin=0, vmax=1), cmap='jet')
        self.fig.colorbar(self.stress_im)
        self.stress_calculator = stress_calculator
        self.nu = nu
        self.myColorMap = colormaps.ScalarMappable(
            norm=colors.Normalize(vmin=0, vmax=1), cmap=colormaps.jet) 
Example 15
Project: fenics-topopt   Author: zfergus   File: stress_gui.py    License: MIT License 5 votes vote down vote up
def __init__(self, nelx, nely, stress_calculator, nu, title=""):
        """Initialize plot and plot the initial design"""
        super(StressGUI, self).__init__(nelx, nely, title)
        self.stress_im = self.ax.imshow(
            np.swapaxes(np.zeros((nelx, nely, 4)), 0, 1),
            norm=colors.Normalize(vmin=0, vmax=1), cmap='jet')
        self.fig.colorbar(self.stress_im)
        self.stress_calculator = stress_calculator
        self.nu = nu
        self.myColorMap = colormaps.ScalarMappable(
            norm=colors.Normalize(vmin=0, vmax=1), cmap=colormaps.jet) 
Example 16
Project: recruit   Author: Frank-qlu   File: test_misc.py    License: Apache License 2.0 5 votes vote down vote up
def test_radviz(self, iris):
        from pandas.plotting import radviz
        from matplotlib import cm

        df = iris
        _check_plot_works(radviz, frame=df, class_column='Name')

        rgba = ('#556270', '#4ECDC4', '#C7F464')
        ax = _check_plot_works(
            radviz, frame=df, class_column='Name', color=rgba)
        # skip Circle drawn as ticks
        patches = [p for p in ax.patches[:20] if p.get_label() != '']
        self._check_colors(
            patches[:10], facecolors=rgba, mapping=df['Name'][:10])

        cnames = ['dodgerblue', 'aquamarine', 'seagreen']
        _check_plot_works(radviz, frame=df, class_column='Name', color=cnames)
        patches = [p for p in ax.patches[:20] if p.get_label() != '']
        self._check_colors(patches, facecolors=cnames, mapping=df['Name'][:10])

        _check_plot_works(radviz, frame=df,
                          class_column='Name', colormap=cm.jet)
        cmaps = lmap(cm.jet, np.linspace(0, 1, df['Name'].nunique()))
        patches = [p for p in ax.patches[:20] if p.get_label() != '']
        self._check_colors(patches, facecolors=cmaps, mapping=df['Name'][:10])

        colors = [[0., 0., 1., 1.],
                  [0., 0.5, 1., 1.],
                  [1., 0., 0., 1.]]
        df = DataFrame({"A": [1, 2, 3],
                        "B": [2, 1, 3],
                        "C": [3, 2, 1],
                        "Name": ['b', 'g', 'r']})
        ax = radviz(df, 'Name', color=colors)
        handles, labels = ax.get_legend_handles_labels()
        self._check_colors(handles, facecolors=colors) 
Example 17
Project: recruit   Author: Frank-qlu   File: test_frame.py    License: Apache License 2.0 5 votes vote down vote up
def test_bar_colors(self):
        import matplotlib.pyplot as plt
        default_colors = self._unpack_cycler(plt.rcParams)

        df = DataFrame(randn(5, 5))
        ax = df.plot.bar()
        self._check_colors(ax.patches[::5], facecolors=default_colors[:5])
        tm.close()

        custom_colors = 'rgcby'
        ax = df.plot.bar(color=custom_colors)
        self._check_colors(ax.patches[::5], facecolors=custom_colors)
        tm.close()

        from matplotlib import cm
        # Test str -> colormap functionality
        ax = df.plot.bar(colormap='jet')
        rgba_colors = lmap(cm.jet, np.linspace(0, 1, 5))
        self._check_colors(ax.patches[::5], facecolors=rgba_colors)
        tm.close()

        # Test colormap functionality
        ax = df.plot.bar(colormap=cm.jet)
        rgba_colors = lmap(cm.jet, np.linspace(0, 1, 5))
        self._check_colors(ax.patches[::5], facecolors=rgba_colors)
        tm.close()

        ax = df.loc[:, [0]].plot.bar(color='DodgerBlue')
        self._check_colors([ax.patches[0]], facecolors=['DodgerBlue'])
        tm.close()

        ax = df.plot(kind='bar', color='green')
        self._check_colors(ax.patches[::5], facecolors=['green'] * 5)
        tm.close() 
Example 18
Project: E-Safenet   Author: c3c   File: compare_keys.py    License: GNU General Public License v2.0 5 votes vote down vote up
def compare_keys():
	keys = []
	freqs = [0]*256
	for f in os.listdir("./keys"):
		with open("./keys/" + f, "rb") as k:
			keys.append(pickle.load(k))
			#freqs.append([0]*256)
	for i in range(512):
		for j in range(len(keys)):
			freqs[keys[j][i]]+=1

	f2 = [x / len(keys) for x in freqs]
	#frequencies put next to each other
	plot.figure(1)
		#print numpy.arange(256) * len(keys) + i
	plot.bar(numpy.arange(256), freqs, color=cm.jet(1.*i/len(keys)))
	plot.ylabel('byte value frequency')
	plot.xlabel('key byte')
	plot.figure(2)
	#keys  put next to eachother
	for i in range(len(keys)):
		plot.bar(numpy.arange(512) * len(keys) + i, keys[i], color=cm.jet(1.*i/len(keys)))

	plot.ylabel('keybyte value')
	plot.xlabel('keys next to eachother (each color is a key)')

	plot.figure(3)
	for i in range(2):
		plot.plot(keys[i])
	

	key = []
	random.seed()
	for i in range(512):
		key.append(random.randint(0, 255))
	plot.plot(key)
	plot.show() 
Example 19
Project: psst   Author: power-system-simulation-toolbox   File: plot.py    License: MIT License 5 votes vote down vote up
def plot_costs(case, number_of_segments=1, ax=None, legend=True):
    if ax is None:
        fig, axs = plt.subplots(1, 1, figsize=(16, 10))
        ax = axs

    color_scale = make_interpolater(0, len(case.gen_name), 0, 1)

    color = {g: plt.cm.jet(color_scale(i)) for i, g in enumerate(case.gen_name)}

    for s in calculate_segments(case, number_of_segments=number_of_segments):
        pmin, pmax = s['segment']
        x = np.linspace(pmin, pmax)
        y = x * s['slope']
        ax.plot(x, y, color=color[s['name']])

    ax = ax.twinx()
    for s in calculate_segments(case, number_of_segments=number_of_segments):
        pmin, pmax = s['segment']
        x = np.linspace(pmin, pmax)
        y = [s['slope'] for _ in x]
        ax.plot(x, y, color=color[s['name']])

    ax.set_ylim(0, 1.2*y[-1])

    if legend:
        lines = list()
        for g in case.gen_name:
            lines.append(mlines.Line2D([], [], color=color[g], label=g))
            ax.legend(handles=lines, loc='upper left')

    return ax 
Example 20
Project: face_classification   Author: oarriaga   File: visualizer.py    License: MIT License 5 votes vote down vote up
def pretty_imshow(axis, data, vmin=None, vmax=None, cmap=None):
    if cmap is None:
        cmap = cm.jet
    if vmin is None:
        vmin = data.min()
    if vmax is None:
        vmax = data.max()
    cax = None
    divider = make_axes_locatable(axis)
    cax = divider.append_axes('right', size='5%', pad=0.05)
    image = axis.imshow(data, vmin=vmin, vmax=vmax,
                        interpolation='nearest', cmap=cmap)
    plt.colorbar(image, cax=cax) 
Example 21
Project: face_classification   Author: oarriaga   File: visualizer.py    License: MIT License 5 votes vote down vote up
def normal_imshow(axis, data, vmin=None, vmax=None,
                  cmap=None, axis_off=True):
    if cmap is None:
        cmap = cm.jet
    if vmin is None:
        vmin = data.min()
    if vmax is None:
        vmax = data.max()
    image = axis.imshow(data, vmin=vmin, vmax=vmax,
                        interpolation='nearest', cmap=cmap)
    if axis_off:
        plt.axis('off')
    return image 
Example 22
Project: deepJDOT   Author: bbdamodaran   File: deepjdot_svhn_mnist.py    License: MIT License 5 votes vote down vote up
def tsne_plot(xs, xt, xs_label, xt_label, subset=True, title=None, pname=None):
    num_test=1000
    import matplotlib.cm as cm
    if subset:
        combined_imgs = np.vstack([xs[0:num_test, :], xt[0:num_test, :]])
        combined_labels = np.vstack([xs_label[0:num_test, :],xt_label[0:num_test, :]])
        combined_labels = combined_labels.astype('int')
        combined_domain = np.vstack([np.zeros((num_test,1)),np.ones((num_test,1))])
    
    from sklearn.manifold import TSNE
    tsne = TSNE(perplexity=30, n_components=2, init='pca', n_iter=3000)
    source_only_tsne = tsne.fit_transform(combined_imgs)
    plt.figure(figsize=(15,15))
    plt.scatter(source_only_tsne[:num_test,0], source_only_tsne[:num_test,1], c=combined_labels[:num_test].argmax(1),
                s=50, alpha=0.5,marker='o', cmap=cm.jet, label='source')
    plt.scatter(source_only_tsne[num_test:,0], source_only_tsne[num_test:,1], c=combined_labels[num_test:].argmax(1),
                s=50, alpha=0.5,marker='+',cmap=cm.jet,label='target')
    plt.axis('off')
    plt.legend(loc='best')
    plt.title(title)
    if filesave:
        plt.savefig(os.path.join(pname,title+'.png'),bbox_inches='tight', pad_inches = 0,
                    format='png')
    else:
        plt.savefig(title+'.png')
    plt.close() 


#%% source model 
Example 23
Project: Emotion   Author: petercunha   File: visualizer.py    License: MIT License 5 votes vote down vote up
def pretty_imshow(axis, data, vmin=None, vmax=None, cmap=None):
    if cmap is None:
        cmap = cm.jet
    if vmin is None:
        vmin = data.min()
    if vmax is None:
        vmax = data.max()
    cax = None
    divider = make_axes_locatable(axis)
    cax = divider.append_axes('right', size='5%', pad=0.05)
    image = axis.imshow(data, vmin=vmin, vmax=vmax,
                        interpolation='nearest', cmap=cmap)
    plt.colorbar(image, cax=cax) 
Example 24
Project: Emotion   Author: petercunha   File: visualizer.py    License: MIT License 5 votes vote down vote up
def normal_imshow(axis, data, vmin=None, vmax=None,
                        cmap=None, axis_off=True):
    if cmap is None:
        cmap = cm.jet
    if vmin is None:
        vmin = data.min()
    if vmax is None:
        vmax = data.max()
    image = axis.imshow(data, vmin=vmin, vmax=vmax,
                        interpolation='nearest', cmap=cmap)
    if axis_off:
        plt.axis('off')
    return image 
Example 25
Project: ocelot   Author: ocelot-collab   File: sr_plot.py    License: GNU General Public License v3.0 5 votes vote down vote up
def D3(screen,Data, distance, file_name = None , unit = "mm", title=None, nfig=1):
    #print " showme.any = ", np.shape(Data)
    X,Y = np.meshgrid(screen.Xph, screen.Yph)
    if unit == "mrad":
        Data = Data*distance*distance*1e-6
        X = X/distance*1e6
        Y = Y/distance*1e6
    fig = plt.figure(nfig)
    if title is not None:
        plt.title(title)
    ax = fig.add_subplot(111, projection='3d')


    #print " showme.any = ", np.shape(X)
    #print " showme.any = ", np.shape(Y)
    data = np.zeros((screen.ny, screen.nx))
    for j in range(screen.ny):
        for i in range(screen.nx):
            data[j,i] = Data[screen.nx*j + i]
    ax.plot_surface(X, Y, data, rstride=1, cstride=1, cmap=cm.jet)
    #ax.set_zlim3d(0, 1)

    if unit == "mrad":
        ax.set_xlabel(r'$\theta_x$, $\mu rad$')
        ax.set_ylabel(r'$\theta_y$, $\mu rad$')
        ax.set_zlabel(r"$I$, $\frac{ph}{s \cdot mrad^2 10^{-3}BW}$")
    else:
        ax.set_xlabel(r'$X$, $mm$')
        ax.set_ylabel(r'$Y$, $mm$')
        ax.set_zlabel(r"$I$, $\frac{ph}{s\cdot mm^2 10^{-3}BW}$")

    #ax.set_xticks([])
    if file_name != None:
        figg = plt.gcf()
        k_size = 1.7
        figg.set_size_inches( (4*k_size, 3.01*k_size) )
        figg.savefig(file_name)
    else:
        plt.show()
    #plt.show() 
Example 26
Project: ocelot   Author: ocelot-collab   File: sr_plot.py    License: GNU General Public License v3.0 5 votes vote down vote up
def plot3D_data(data, x = None, y = None):
    if x != None and y != None:
        X,Y = np.meshgrid(x,y)
    else:
        print( np.shape(data))
        X,Y = np.meshgrid(np.arange(np.shape(data)[1]), np.arange(np.shape(data)[0]))
    fig = plt.figure()
    ax = fig.add_subplot(111, projection='3d')
    ax.plot_surface(X, Y, data, rstride=1, cstride=1, cmap=cm.jet)
    plt.show() 
Example 27
Project: vnpy_crypto   Author: birforce   File: test_misc.py    License: MIT License 5 votes vote down vote up
def test_radviz(self, iris):
        from pandas.plotting import radviz
        from matplotlib import cm

        df = iris
        _check_plot_works(radviz, frame=df, class_column='Name')

        rgba = ('#556270', '#4ECDC4', '#C7F464')
        ax = _check_plot_works(
            radviz, frame=df, class_column='Name', color=rgba)
        # skip Circle drawn as ticks
        patches = [p for p in ax.patches[:20] if p.get_label() != '']
        self._check_colors(
            patches[:10], facecolors=rgba, mapping=df['Name'][:10])

        cnames = ['dodgerblue', 'aquamarine', 'seagreen']
        _check_plot_works(radviz, frame=df, class_column='Name', color=cnames)
        patches = [p for p in ax.patches[:20] if p.get_label() != '']
        self._check_colors(patches, facecolors=cnames, mapping=df['Name'][:10])

        _check_plot_works(radviz, frame=df,
                          class_column='Name', colormap=cm.jet)
        cmaps = lmap(cm.jet, np.linspace(0, 1, df['Name'].nunique()))
        patches = [p for p in ax.patches[:20] if p.get_label() != '']
        self._check_colors(patches, facecolors=cmaps, mapping=df['Name'][:10])

        colors = [[0., 0., 1., 1.],
                  [0., 0.5, 1., 1.],
                  [1., 0., 0., 1.]]
        df = DataFrame({"A": [1, 2, 3],
                        "B": [2, 1, 3],
                        "C": [3, 2, 1],
                        "Name": ['b', 'g', 'r']})
        ax = radviz(df, 'Name', color=colors)
        handles, labels = ax.get_legend_handles_labels()
        self._check_colors(handles, facecolors=colors) 
Example 28
Project: vnpy_crypto   Author: birforce   File: test_frame.py    License: MIT License 5 votes vote down vote up
def test_bar_colors(self):
        import matplotlib.pyplot as plt
        default_colors = self._maybe_unpack_cycler(plt.rcParams)

        df = DataFrame(randn(5, 5))
        ax = df.plot.bar()
        self._check_colors(ax.patches[::5], facecolors=default_colors[:5])
        tm.close()

        custom_colors = 'rgcby'
        ax = df.plot.bar(color=custom_colors)
        self._check_colors(ax.patches[::5], facecolors=custom_colors)
        tm.close()

        from matplotlib import cm
        # Test str -> colormap functionality
        ax = df.plot.bar(colormap='jet')
        rgba_colors = lmap(cm.jet, np.linspace(0, 1, 5))
        self._check_colors(ax.patches[::5], facecolors=rgba_colors)
        tm.close()

        # Test colormap functionality
        ax = df.plot.bar(colormap=cm.jet)
        rgba_colors = lmap(cm.jet, np.linspace(0, 1, 5))
        self._check_colors(ax.patches[::5], facecolors=rgba_colors)
        tm.close()

        ax = df.loc[:, [0]].plot.bar(color='DodgerBlue')
        self._check_colors([ax.patches[0]], facecolors=['DodgerBlue'])
        tm.close()

        ax = df.plot(kind='bar', color='green')
        self._check_colors(ax.patches[::5], facecolors=['green'] * 5)
        tm.close() 
Example 29
Project: Face-and-Emotion-Recognition   Author: vjgpt   File: visualizer.py    License: MIT License 5 votes vote down vote up
def pretty_imshow(axis, data, vmin=None, vmax=None, cmap=None):
    if cmap is None:
        cmap = cm.jet
    if vmin is None:
        vmin = data.min()
    if vmax is None:
        vmax = data.max()
    cax = None
    divider = make_axes_locatable(axis)
    cax = divider.append_axes('right', size='5%', pad=0.05)
    image = axis.imshow(data, vmin=vmin, vmax=vmax,
                        interpolation='nearest', cmap=cmap)
    plt.colorbar(image, cax=cax) 
Example 30
Project: Face-and-Emotion-Recognition   Author: vjgpt   File: visualizer.py    License: MIT License 5 votes vote down vote up
def normal_imshow(axis, data, vmin=None, vmax=None,
                        cmap=None, axis_off=True):
    if cmap is None:
        cmap = cm.jet
    if vmin is None:
        vmin = data.min()
    if vmax is None:
        vmax = data.max()
    image = axis.imshow(data, vmin=vmin, vmax=vmax,
                        interpolation='nearest', cmap=cmap)
    if axis_off:
        plt.axis('off')
    return image