当前位置: 首页>>代码示例>>Python>>正文


Python pylab.subplots方法代码示例

本文整理汇总了Python中matplotlib.pylab.subplots方法的典型用法代码示例。如果您正苦于以下问题:Python pylab.subplots方法的具体用法?Python pylab.subplots怎么用?Python pylab.subplots使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在matplotlib.pylab的用法示例。


在下文中一共展示了pylab.subplots方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_plotting

# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import subplots [as 别名]
def test_plotting(self):
        """
        This test is just to document current use in libraries in case of refactoring
        """
        corrs = np.array([.6, .2, .1, .001])
        errs = np.array([.1, .05, .04, .0005])
        fig, ax1 = plt.subplots(1, 1, figsize=(5, 5))
        cca.plot_correlations(corrs, errs, ax=ax1, color='blue')
        cca.plot_correlations(corrs * .1, errs, ax=ax1, color='orange')

    # Shuffle data
    # ...
    # fig, ax1 = plt.subplots(1,1,figsize(10,10))
    # plot_correlations(corrs, ... , ax=ax1, color='blue')
    # plot_correlations(shuffled_coors, ..., ax=ax1, color='red')
    # plt.show() 
开发者ID:int-brain-lab,项目名称:ibllib,代码行数:18,代码来源:test_cca.py

示例2: plot_metrics

# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import subplots [as 别名]
def plot_metrics(metric_list, save_path=None):
    # runs through each test case and adds a set of bars to a plot.  Saves

    f, (ax1) = plt.subplots(1, 1)
    plt.grid(True)

    print_metrics(metric_list)

    bar_metrics(metric_list[0], ax1, index=0)
    bar_metrics(metric_list[1], ax1, index=1)
    bar_metrics(metric_list[2], ax1, index=2)

    if save_path is None:
        save_path = "img/bar_" + key + ".png"

    plt.savefig(save_path, dpi=400) 
开发者ID:RasaHQ,项目名称:rasa_lookup_demo,代码行数:18,代码来源:run_lookup.py

示例3: create_figure

# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import subplots [as 别名]
def create_figure(im_size, figsize_max=MAX_FIGURE_SIZE):
    """ create an empty figure of image size maximise maximal size

    :param tuple(int,int) im_size:
    :param float figsize_max:
    :return:

    >>> fig, ax = create_figure((100, 150))
    >>> isinstance(fig, plt.Figure)
    True
    """
    assert len(im_size) >= 2, 'not valid image size - %r' % im_size
    size = np.array(im_size[:2])
    fig_size = size[::-1] / float(size.max()) * figsize_max
    fig, ax = plt.subplots(figsize=fig_size)
    return fig, ax 
开发者ID:Borda,项目名称:BIRL,代码行数:18,代码来源:drawing.py

示例4: plot

# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import subplots [as 别名]
def plot(self):
        try:
            import pandas as pd
            import matplotlib.pylab as plt
            df = pd.DataFrame(self.history).set_index(['id', 'generation']).fillna(0)
            population_size = sum(df.iloc[0].values)
            n_populations = df.reset_index()['id'].nunique()
            fig, axes = plt.subplots(nrows=n_populations, figsize=(12, 2*n_populations),
                                     sharex='all', sharey='all', squeeze=False)
            for row, (_, pop) in zip(axes, df.groupby('id')):
                ax = row[0]
                pop.reset_index(level='id', drop=True).plot(ax=ax)
                ax.set_ylim([0, population_size])
                ax.set_xlabel('iteration')
                ax.set_ylabel('# w/ preference')
                if n_populations > 1:
                    for i in range(0, df.reset_index().generation.max(), 50):
                        ax.axvline(i)
            plt.show()
        except ImportError:
            print("If you install matplotlib and pandas you will get a pretty plot.") 
开发者ID:godatadriven,项目名称:evol,代码行数:23,代码来源:rock_paper_scissors.py

示例5: plot_trajectory

# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import subplots [as 别名]
def plot_trajectory(name):
    STEPS = 600
    DELTA = 1 if name != 'linear' else 0.1
    trajectory = create_trajectory(name, STEPS)

    x = [trajectory.get_position_at(i * DELTA).x for i in range(STEPS)]
    y = [trajectory.get_position_at(i * DELTA).y for i in range(STEPS)]

    trajectory_fig, trajectory_plot = plt.subplots(1, 1)
    trajectory_plot.plot(x, y, label='trajectory', lw=3)
    trajectory_plot.set_title(name.title() + ' Trajectory', fontsize=20)
    trajectory_plot.set_xlabel(r'$x{\rm[m]}$', fontsize=18)
    trajectory_plot.set_ylabel(r'$y{\rm[m]}$', fontsize=18)
    trajectory_plot.legend(loc=0)
    trajectory_plot.grid()
    plt.show() 
开发者ID:lmiguelvargasf,项目名称:trajectory_tracking,代码行数:18,代码来源:menu.py

示例6: plot_alignment_to_numpy

# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import subplots [as 别名]
def plot_alignment_to_numpy(alignment, info=None):
    fig, ax = plt.subplots(figsize=(6, 4))
    im = ax.imshow(alignment, aspect='auto', origin='lower',
                   interpolation='none')
    fig.colorbar(im, ax=ax)
    xlabel = 'Decoder timestep'
    if info is not None:
        xlabel += '\n\n' + info
    plt.xlabel(xlabel)
    plt.ylabel('Encoder timestep')
    plt.tight_layout()

    fig.canvas.draw()
    data = save_figure_to_numpy(fig)
    plt.close()
    return data 
开发者ID:jxzhanggg,项目名称:nonparaSeq2seqVC_code,代码行数:18,代码来源:plotting_utils.py

示例7: train

# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import subplots [as 别名]
def train(self):
        """
        训练
        """
        training_set,test_set, training_inputs, training_target, test_inputs, test_targets = self.getData()

        eth_model = self.buildModel(training_inputs, 1, 20)
        training_target = (training_set["eth_Close"][self.window_len:].values /
                           training_set['eth_Close'][:-self.window_len].values) - 1

        eth_history = eth_model.fit(training_inputs, training_target,
                                    epochs=self.epochs, batch_size=self.batch_size,
                                    verbose=self.verbose, shuffle=True)

        fig, ax1 = plt.subplots(1, 1)
        ax1.plot(eth_history.epoch, eth_history.history['loss'])
        ax1.set_title('Training Loss')
        ax1.set_ylabel('MAE',fontsize=12)
        ax1.set_xlabel('# Epochs',fontsize=12)
        plt.show() 
开发者ID:jarvisqi,项目名称:deep_learning,代码行数:22,代码来源:bitcoin_price.py

示例8: real

# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import subplots [as 别名]
def real(val, outline=None, ax=None, cbar=False, cmap='RdBu', outline_alpha=0.5):
    """Plots the real part of 'val', optionally overlaying an outline of 'outline'
    """

    if ax is None:
        fig, ax = plt.subplots(1, 1, constrained_layout=True)
    
    vmax = np.abs(val).max()
    h = ax.imshow(np.real(val.T), cmap=cmap, origin='lower left', vmin=-vmax, vmax=vmax)
    
    if outline is not None:
        ax.contour(outline.T, 0, colors='k', alpha=outline_alpha)
    
    ax.set_ylabel('y')
    ax.set_xlabel('x')
    if cbar:
        plt.colorbar(h, ax=ax)
    
    return ax 
开发者ID:fancompute,项目名称:ceviche,代码行数:21,代码来源:viz.py

示例9: abs

# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import subplots [as 别名]
def abs(val, outline=None, ax=None, cbar=False, cmap='magma', outline_alpha=0.5, outline_val=None):
    """Plots the absolute value of 'val', optionally overlaying an outline of 'outline'
    """
    
    if ax is None:
        fig, ax = plt.subplots(1, 1, constrained_layout=True)      
    
    vmax = np.abs(val).max()
    h = ax.imshow(np.abs(val.T), cmap=cmap, origin='lower left', vmin=0, vmax=vmax)
    
    if outline_val is None and outline is not None: outline_val = 0.5*(outline.min()+outline.max())
    if outline is not None:
        ax.contour(outline.T, [outline_val], colors='w', alpha=outline_alpha)
    
    ax.set_ylabel('y')
    ax.set_xlabel('x')
    if cbar:
        plt.colorbar(h, ax=ax)
    
    return ax 
开发者ID:fancompute,项目名称:ceviche,代码行数:22,代码来源:viz.py

示例10: test_fields_H

# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import subplots [as 别名]
def test_fields_H(self):

        F = fdtd(self.eps_r, dL=self.dL, npml=self.pml)

        fig, ax = plt.subplots(figsize=(10, 10))
        im = ax.pcolormesh(np.zeros((self.Nx, self.Ny)), cmap='RdBu')

        for t_index in range(self.steps):

            fields = F.forward(Jx=self.gaussian(t_index))

            if t_index % self.skip_rate == 0:

                max_E = np.abs(fields['Hz']).max()
                im.set_array(fields['Hz'][:, :, 0].ravel())
                im.set_clim([-1, 1])
                plt.pause(0.001)
                ax.set_title('time = {}'.format(t_index)) 
开发者ID:fancompute,项目名称:ceviche,代码行数:20,代码来源:test_fields_fdtd.py

示例11: plot_gate_outputs_to_numpy

# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import subplots [as 别名]
def plot_gate_outputs_to_numpy(gate_targets, gate_outputs):
    fig, ax = plt.subplots(figsize=(12, 3))
    ax.scatter(
        range(len(gate_targets)), gate_targets, alpha=0.5, color='green', marker='+', s=1, label='target',
    )
    ax.scatter(
        range(len(gate_outputs)), gate_outputs, alpha=0.5, color='red', marker='.', s=1, label='predicted',
    )

    plt.xlabel("Frames (Green target, Red predicted)")
    plt.ylabel("Gate State")
    plt.tight_layout()

    fig.canvas.draw()
    data = save_figure_to_numpy(fig)
    plt.close()
    return data 
开发者ID:NVIDIA,项目名称:NeMo,代码行数:19,代码来源:helpers.py

示例12: plot_true_and_augmented_data

# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import subplots [as 别名]
def plot_true_and_augmented_data(sample,noised_sample,label,n_examples):
    output_dir = os.path.split(FLAGS.output)[0]
    # Save augmented data
    plt.clf()
    fig, ax = plt.subplots(3,1)
    for t in range(noised_sample.shape[1]):
        ax[t].plot(noised_sample[:,t])
        ax[t].set_xlabel('time (samples)')
        ax[t].set_ylabel('amplitude')
    ax[0].set_title('window {:03d}, cluster_id: {}'.format(n_examples,label))
    plt.savefig(os.path.join(output_dir, "augmented_data",
                            'augmented_{:03d}.pdf'.format(n_examples)))
    plt.close()

    # Save true data
    plt.clf()
    fig, ax = plt.subplots(3,1)
    for t in range(sample.shape[1]):
        ax[t].plot(sample[:,t])
        ax[t].set_xlabel('time (samples)')
        ax[t].set_ylabel('amplitude')
    ax[0].set_title('window {:03d}, cluster_id: {}'.format(n_examples,label))
    plt.savefig(os.path.join(output_dir, "true_data",
                            'true__{:03d}.pdf'.format(n_examples)))
    plt.close() 
开发者ID:tperol,项目名称:ConvNetQuake,代码行数:27,代码来源:data_augmentation.py

示例13: plot_losses

# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import subplots [as 别名]
def plot_losses(losses_d, losses_g, filename):
    losses_d = np.array(losses_d)
    fig, axes = plt.subplots(3, 2, figsize=(8, 8))
    axes = axes.flatten()
    axes[0].plot(losses_d[:, 0])
    axes[1].plot(losses_d[:, 1])
    axes[2].plot(losses_d[:, 2])
    axes[3].plot(losses_d[:, 3])
    axes[4].plot(losses_g)
    axes[0].set_title("losses_d")
    axes[1].set_title("losses_d_real")
    axes[2].set_title("losses_d_fake")
    axes[3].set_title("losses_d_gp")
    axes[4].set_title("losses_g")
    plt.tight_layout()
    plt.savefig(filename)
    plt.close() 
开发者ID:PacktPublishing,项目名称:Hands-On-Generative-Adversarial-Networks-with-Keras,代码行数:19,代码来源:resnet_wgan_gp_cifar10_train.py

示例14: showVector

# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import subplots [as 别名]
def showVector(df,columnName):
    # print(df.columns)
    #可以显示vecter(polygon,point)数据。show vector
    multi=2
    fig, ax = plt.subplots(figsize=(14*multi, 8*multi))
    df.plot(column=columnName,
            categorical=True,
            legend=True,
            scheme='QUANTILES',
            cmap='RdBu', #'OrRd'
            ax=ax)
    # df.plot()
    # adjust legend location
    leg = ax.get_legend()
    # leg.set_bbox_to_anchor((1.15,0.5))
    ax.set_axis_off()    
    plt.show()  
    
 # As provided in the answer by Divakar  https://stackoverflow.com/questions/41190852/most-efficient-way-to-forward-fill-nan-values-in-numpy-array 
开发者ID:richieBao,项目名称:python-urbanPlanning,代码行数:21,代码来源:equality and segregation.py

示例15: showVector

# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import subplots [as 别名]
def showVector(df,columnName):
    # print(df.columns)
    #可以显示vecter(polygon,point)数据。show vector
    multi=2
    fig, ax = plt.subplots(figsize=(14*multi, 8*multi))
    df.plot(column=columnName,
            categorical=True,
            legend=True,
            scheme='QUANTILES',
            cmap='RdBu', #'OrRd'
            ax=ax)
    # df.plot()
    # adjust legend location
    leg = ax.get_legend()
    # leg.set_bbox_to_anchor((1.15,0.5))
    ax.set_axis_off()    
    plt.show()  


    
#Spatial_Autocorrelation_for_Areal_Unit_Data 
开发者ID:richieBao,项目名称:python-urbanPlanning,代码行数:23,代码来源:Exploratory Spatial Data Analysis in PySAL.py


注:本文中的matplotlib.pylab.subplots方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。