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


Python pylab.rc方法代码示例

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


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

示例1: __init__

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import rc [as 别名]
def __init__(self, add_inputs, title='', **kwargs):
        super(OffshorePlot, self).__init__(**kwargs)
        self.fig = plt.figure(num=None, facecolor='w', edgecolor='k') #figsize=(13, 8), dpi=1000
        self.shape_plot = self.fig.add_subplot(121)
        self.objf_plot = self.fig.add_subplot(122)

        self.targname = add_inputs
        self.title = title

        # Adding automatically the inputs
        for i in add_inputs:
            self.add(i, Float(0.0, iotype='in'))

        #sns.set(style="darkgrid")
        #self.pal = sns.dark_palette("skyblue", as_cmap=True)
        plt.rc('lines', linewidth=1)
        plt.ion()
        self.force_execute = True
        if not pa('fig').exists():
            pa('fig').mkdir() 
开发者ID:DTUWindEnergy,项目名称:TOPFARM,代码行数:22,代码来源:plot.py

示例2: plot_parametertrace_algorithms

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import rc [as 别名]
def plot_parametertrace_algorithms(result_lists, algorithmnames, spot_setup, 
                                   fig_name='parametertrace_algorithms.png'):
    """Example Plot as seen in the SPOTPY Documentation"""
    import matplotlib.pyplot as plt
    font = {'family' : 'calibri',
        'weight' : 'normal',
        'size'   : 20}
    plt.rc('font', **font)
    fig=plt.figure(figsize=(17,5))
    subplots=len(result_lists)
    parameter = spotpy.parameter.get_parameters_array(spot_setup)
    rows=len(parameter['name'])
    for j in range(rows):
        for i in range(subplots):
            ax  = plt.subplot(rows,subplots,i+1+j*subplots)
            data=result_lists[i]['par'+parameter['name'][j]]
            ax.plot(data,'b-')
            if i==0:
                ax.set_ylabel(parameter['name'][j])
                rep = len(data)
            if i>0:
                ax.yaxis.set_ticks([])
            if j==rows-1:
                ax.set_xlabel(algorithmnames[i-subplots])
            else:
                ax.xaxis.set_ticks([])
            ax.plot([1]*rep,'r--')
            ax.set_xlim(0,rep)
            ax.set_ylim(parameter['minbound'][j],parameter['maxbound'][j])
            
    #plt.tight_layout()
    fig.savefig(fig_name, bbox_inches='tight') 
开发者ID:thouska,项目名称:spotpy,代码行数:34,代码来源:analyser.py

示例3: plot_objectivefunctiontraces

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import rc [as 别名]
def plot_objectivefunctiontraces(results,evaluation,algorithms,fig_name='Like_trace.png'):
    import matplotlib.pyplot as plt
    from matplotlib import colors
    cnames=list(colors.cnames)
    font = {'family' : 'calibri',
        'weight' : 'normal',
        'size'   : 20}
    plt.rc('font', **font)
    fig=plt.figure(figsize=(16,3))
    xticks=[5000,15000]

    for i in range(len(results)):
        ax  = plt.subplot(1,len(results),i+1)
        likes=calc_like(results[i],evaluation,spotpy.objectivefunctions.rmse)
        ax.plot(likes,'b-')
        ax.set_ylim(0,25)
        ax.set_xlim(0,len(results[0]))
        ax.set_xlabel(algorithms[i])
        ax.xaxis.set_ticks(xticks)
        if i==0:
            ax.set_ylabel('RMSE')
            ax.yaxis.set_ticks([0,10,20])
        else:
            ax.yaxis.set_ticks([])

    plt.tight_layout()
    fig.savefig(fig_name) 
开发者ID:thouska,项目名称:spotpy,代码行数:29,代码来源:analyser.py

示例4: analyse_

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import rc [as 别名]
def analyse_(self, inputs, outputs, idx2word, inputs_unk=None, return_attend=False, name=None, display=False):
        def cut_zero(sample, idx2word, ppp=None, Lmax=None):
            if Lmax is None:
                Lmax = self.config['dec_voc_size']
            if ppp is None:
                if 0 not in sample:
                    return ['{}'.format(idx2word[w].encode('utf-8'))
                            if w < Lmax else '{}'.format(idx2word[inputs[w - Lmax]].encode('utf-8'))
                            for w in sample]

                return ['{}'.format(idx2word[w].encode('utf-8'))
                        if w < Lmax else '{}'.format(idx2word[inputs[w - Lmax]].encode('utf-8'))
                        for w in sample[:sample.index(0)]]
            else:
                if 0 not in sample:
                    return ['{0} ({1:1.1f})'.format(
                            idx2word[w].encode('utf-8'), p)
                            if w < Lmax
                            else '{0} ({1:1.1f})'.format(
                            idx2word[inputs[w - Lmax]].encode('utf-8'), p)
                            for w, p in zip(sample, ppp)]
                idz = sample.index(0)
                return ['{0} ({1:1.1f})'.format(
                        idx2word[w].encode('utf-8'), p)
                        if w < Lmax
                        else '{0} ({1:1.1f})'.format(
                        idx2word[inputs[w - Lmax]].encode('utf-8'), p)
                        for w, p in zip(sample[:idz], ppp[:idz])]

        if inputs_unk is None:
            result, _, ppp = self.generate_(inputs[None, :],
                                            return_attend=return_attend)
        else:
            result, _, ppp = self.generate_(inputs_unk[None, :],
                                            return_attend=return_attend)

        source = '{}'.format(' '.join(cut_zero(inputs.tolist(),  idx2word, Lmax=len(idx2word))))
        target = '{}'.format(' '.join(cut_zero(outputs.tolist(), idx2word, Lmax=len(idx2word))))
        decode = '{}'.format(' '.join(cut_zero(result, idx2word)))

        if display:
            print(source)
            print(target)
            print(decode)

            idz    = result.index(0)
            p1, p2 = [np.asarray(p) for p in zip(*ppp)]
            print(p1.shape)
            import pylab as plt
            # plt.rc('text', usetex=True)
            # plt.rc('font', family='serif')
            visualize_(plt.subplots(), 1 - p1[:idz, :].T, grid=True, name=name)
            visualize_(plt.subplots(), 1 - p2[:idz, :].T, name=name)

            # visualize_(plt.subplots(), 1 - np.mean(p2[:idz, :], axis=1, keepdims=True).T)
        return target == decode 
开发者ID:memray,项目名称:seq2seq-keyphrase,代码行数:58,代码来源:covc_encdec.py

示例5: plot_heatmap_griewank

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import rc [as 别名]
def plot_heatmap_griewank(results,algorithms, fig_name='heatmap_griewank.png'):
    """Example Plot as seen in the SPOTPY Documentation"""
    import matplotlib.pyplot as plt

    from matplotlib import ticker
    from matplotlib import cm
    font = {'family' : 'calibri',
        'weight' : 'normal',
        'size'   : 20}
    plt.rc('font', **font)
    subplots=len(results)
    xticks=[-40,0,40]
    yticks=[-40,0,40]
    fig=plt.figure(figsize=(16,6))
    N = 2000
    x = np.linspace(-50.0, 50.0, N)
    y = np.linspace(-50.0, 50.0, N)

    x, y = np.meshgrid(x, y)

    z=1+ (x**2+y**2)/4000 - np.cos(x/np.sqrt(2))*np.cos(y/np.sqrt(3))

    cmap = plt.get_cmap('autumn')

    rows=2.0
    for i in range(subplots):
        amount_row = int(np.ceil(subplots/rows))
        ax = plt.subplot(rows, amount_row, i+1)
        CS = ax.contourf(x, y, z,locator=ticker.LogLocator(),cmap=cm.rainbow)

        ax.plot(results[i]['par0'],results[i]['par1'],'ko',alpha=0.2,markersize=1.9)
        ax.xaxis.set_ticks([])
        if i==0:
            ax.set_ylabel('y')
        if i==subplots/rows:
            ax.set_ylabel('y')
        if i>=subplots/rows:
            ax.set_xlabel('x')
            ax.xaxis.set_ticks(xticks)

        if i!=0 and i!=subplots/rows:
            ax.yaxis.set_ticks([])


        ax.set_title(algorithms[i])

    fig.savefig(fig_name, bbox_inches='tight') 
开发者ID:thouska,项目名称:spotpy,代码行数:49,代码来源:analyser.py

示例6: plot

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import rc [as 别名]
def plot(self,mo_matrix,symmetry='1',title='All',x_label='index',
           y_label='MO coefficients',output_format='png',
           plt_dir='Plots',ylim=None,thresh=0.1,x0=0,grid=True,x_grid=None,**kwargs):
    '''Plots all molecular orbital coefficients of one self.symmetry.'''
    import pylab as plt
    from matplotlib.ticker import MultipleLocator
    import os
    
    display('Plotting data of self.symmetry %s to %s/' % (symmetry,plt_dir))
    if not os.path.exists(plt_dir):
      os.makedirs(plt_dir)
    
    if numpy.ndim(mo_matrix) == 2:
      mo_matrix = mo_matrix[:,numpy.newaxis,:]
    
    shape = numpy.shape(mo_matrix)
    
    
    def plot_mo(i):
      fig=plt.figure()
      plt.rc('xtick', labelsize=16) 
      plt.rc('ytick', labelsize=16)
      ax = plt.subplot(111)
      curves=[]
      for ij in range(shape[2]):
        Y = mo_matrix[:,i,ij]
        if x_grid is None:
          X = numpy.arange(len(Y))+x0
        else:
          X = x_grid
        if max(numpy.abs(Y)) > thresh:
          curves.append(ax.plot(X,Y, '.-' ,linewidth=1.5))
      
      
      plt.xlabel(x_label, fontsize=16);
      plt.ylabel(y_label, fontsize=16);
      plt.title('%s: %d.%s'%  (title,i+1,symmetry))
      plt.ylim(ylim)
      
      plt.tight_layout()
      return fig
    
    if output_format == 'pdf':
      from matplotlib.backends.backend_pdf import PdfPages
      output_fid = '%s.%s.pdf'% (title,symmetry.replace(' ','_'))
      display('\t%s' % output_fid)
      with PdfPages(os.path.join(plt_dir,output_fid)) as pdf:
        for i in range(shape[1]):
          fig = plot_mo(i)
          pdf.savefig(fig,**kwargs)
          plt.close()
    elif output_format == 'png':
      for i in range(shape[1]):
        fig = plot_mo(i)
        output_fid = '%d.%s.png' % (i+1,symmetry.replace(' ','_'))
        display('\t%s' % output_fid)
        fig.savefig(os.path.join(plt_dir, output_fid),format='png',**kwargs)
        plt.close()
    else:
      raise ValueError('output_format `%s` is not supported' % output_format) 
开发者ID:orbkit,项目名称:orbkit,代码行数:62,代码来源:multiple_files.py

示例7: analyse_

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import rc [as 别名]
def analyse_(self, inputs, outputs, idx2word, inputs_unk=None, return_attend=False, name=None, display=False):
        def cut_zero(sample, idx2word, ppp=None, Lmax=None):
            if Lmax is None:
                Lmax = self.config['dec_voc_size']
            if ppp is None:
                if 0 not in sample:
                    return ['{}'.format(idx2word[w].encode('utf-8'))
                            if w < Lmax else '{}'.format(idx2word[inputs[w - Lmax]].encode('utf-8'))
                            for w in sample]

                return ['{}'.format(idx2word[w].encode('utf-8'))
                        if w < Lmax else '{}'.format(idx2word[inputs[w - Lmax]].encode('utf-8'))
                        for w in sample[:sample.index(0)]]
            else:
                if 0 not in sample:
                    return ['{0} ({1:1.1f})'.format(
                            idx2word[w].encode('utf-8'), p)
                            if w < Lmax
                            else '{0} ({1:1.1f})'.format(
                            idx2word[inputs[w - Lmax]].encode('utf-8'), p)
                            for w, p in zip(sample, ppp)]
                idz = sample.index(0)
                return ['{0} ({1:1.1f})'.format(
                        idx2word[w].encode('utf-8'), p)
                        if w < Lmax
                        else '{0} ({1:1.1f})'.format(
                        idx2word[inputs[w - Lmax]].encode('utf-8'), p)
                        for w, p in zip(sample[:idz], ppp[:idz])]

        if inputs_unk is None:
            result, _, ppp = self.generate_(inputs[None, :],
                                            return_attend=return_attend)
        else:
            result, _, ppp = self.generate_(inputs_unk[None, :],
                                            return_attend=return_attend)

        source = '{}'.format(' '.join(cut_zero(inputs.tolist(),  idx2word, Lmax=len(idx2word))))
        target = '{}'.format(' '.join(cut_zero(outputs.tolist(), idx2word, Lmax=len(idx2word))))
        decode = '{}'.format(' '.join(cut_zero(result, idx2word)))

        if display:
            print source
            print target
            print decode

            idz    = result.index(0)
            p1, p2 = [np.asarray(p) for p in zip(*ppp)]
            print p1.shape
            import pylab as plt
            # plt.rc('text', usetex=True)
            # plt.rc('font', family='serif')
            visualize_(plt.subplots(), 1 - p1[:idz, :].T, grid=True, name=name)
            visualize_(plt.subplots(), 1 - p2[:idz, :].T, name=name)

            # visualize_(plt.subplots(), 1 - np.mean(p2[:idz, :], axis=1, keepdims=True).T)
        return target == decode 
开发者ID:MultiPath,项目名称:CopyNet,代码行数:58,代码来源:covc_encdec.py


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