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


Python plt.close函数代码示例

本文整理汇总了Python中pylab.plt.close函数的典型用法代码示例。如果您正苦于以下问题:Python close函数的具体用法?Python close怎么用?Python close使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: pure_data_plot

 def pure_data_plot(self,connect=False,suffix='',cmap=cm.jet,bg=cm.bone(0.3)):
     #fig=plt.figure()
     ax=plt.axes()
     plt.axhline(y=0,color='grey', zorder=-1)
     plt.axvline(x=0,color='grey', zorder=-2)
     if cmap is None:
         if connect: ax.plot(self.x,self.y, 'b-',lw=2,alpha=0.5)
         ax.scatter(self.x,self.y, marker='o', c='b', s=40)
     else:
         if connect:
             if cmap in [cm.jet,cm.brg]:
                 ax.plot(self.x,self.y, 'c-',lw=2,alpha=0.5,zorder=-1)
             else:
                 ax.plot(self.x,self.y, 'b-',lw=2,alpha=0.5)
         c=[cmap((f-self.f[0])/(self.f[-1]-self.f[0])) for f in self.f]
         #c=self.f
         ax.scatter(self.x, self.y, marker='o', c=c, edgecolors=c, zorder=True, s=40) #, cmap=cmap)
     #plt.axis('equal')
     ax.set_xlim(xmin=-0.2*amax(self.x), xmax=1.2*amax(self.x))
     ax.set_aspect('equal')  #, 'datalim')
     if cmap in [cm.jet,cm.brg]:
         ax.set_axis_bgcolor(bg)
     if self.ZorY == 'Z':
         plt.xlabel(r'resistance $R$ in Ohm'); plt.ylabel(r'reactance $X$ in Ohm')
     if self.ZorY == 'Y':
         plt.xlabel(r'conductance $G$ in Siemens'); plt.ylabel(r'susceptance $B$ in Siemens')
     if self.show: plt.show()
     else: plt.savefig(join(self.sdc.plotpath,'c{}_{}_circle_data'.format(self.sdc.case,self.ZorY)+self.sdc.suffix+self.sdc.outsuffix+suffix+'.png'), dpi=240)
     plt.close()
开发者ID:antiface,项目名称:zycircle,代码行数:29,代码来源:ZYCircle.py

示例2: plot_stat

def plot_stat(rows, cache):
    "Use matplotlib to plot DAS statistics"
    if  not PLOT_ALLOWED:
        raise Exception('Matplotlib is not available on the system')
    if  cache in ['cache', 'merge']: # cachein, cacheout, mergein, mergeout
        name_in  = '%sin' % cache
        name_out = '%sout' % cache
    else: # webip, webq, cliip, cliq
        name_in  = '%sip' % cache
        name_out = '%sq' % cache
    def format_date(date):
        "Format given date"
        val = str(date)
        return '%s-%s-%s' % (val[:4], val[4:6], val[6:8])
    date_range = [r['date'] for r in rows]
    formated_dates = [format_date(str(r['date'])) for r in rows]
    req_in  = [r[name_in] for r in rows]
    req_out = [r[name_out] for r in rows]

    plt.plot(date_range, req_in , 'ro-',
             date_range, req_out, 'gv-',
    )
    plt.grid(True)
    plt.axis([min(date_range), max(date_range), \
                0, max([max(req_in), max(req_out)])])
    plt.xticks(date_range, tuple(formated_dates), rotation=17)
#    plt.xlabel('dates [%s, %s]' % (date_range[0], date_range[-1]))
    plt.ylabel('DAS %s behavior' % cache)
    plt.savefig('das_%s.pdf' % cache, format='pdf', transparent=True)
    plt.close()
开发者ID:zdenekmaxa,项目名称:DAS,代码行数:30,代码来源:das_stats.py

示例3: link_level_bars

def link_level_bars(levels, usages, quantiles, scheme, direction, color, nnames, lnames, admat=None):
    """
    Bar plots of nodes' link usage of links at different levels.
    """
    if not admat:
        admat = np.genfromtxt('./settings/eadmat.txt')
    if color == 'solar':
        cmap = Oranges_cmap
    elif color == 'wind':
        cmap = Blues_cmap
    elif color == 'backup':
        cmap = 'Greys'
    nodes, links = usages.shape
    usageLevels = np.zeros((nodes, levels))
    usageLevelsNorm = np.zeros((nodes, levels))
    for node in range(nodes):
        nl = neighbor_levels(node, levels, admat)
        for lvl in range(levels):
            ll = link_level(nl, lvl, nnames, lnames)
            ll = np.array(ll, dtype='int')
            usageSum = sum(usages[node, ll])
            linkSum = sum(quantiles[ll])
            usageLevels[node, lvl] = usageSum / linkSum
            if lvl == 0:
                usageLevelsNorm[node, lvl] = usageSum
            else:
                usageLevelsNorm[node, lvl] = usageSum / usageLevelsNorm[node, 0]
        usageLevelsNorm[:, 0] = 1

    # plot all nodes
    usages = usageLevels.transpose()
    plt.figure(figsize=(11, 3))
    ax = plt.subplot()
    plt.pcolormesh(usages[:, loadOrder], cmap=cmap)
    plt.colorbar().set_label(label=r'$U_n^{(l)}$', size=11)
    ax.set_yticks(np.linspace(.5, levels - .5, levels))
    ax.set_yticklabels(range(1, levels + 1))
    ax.yaxis.set_tick_params(width=0)
    ax.xaxis.set_tick_params(width=0)
    ax.set_xticks(np.linspace(1, nodes, nodes))
    ax.set_xticklabels(loadNames, rotation=60, ha="right", va="top", fontsize=10)
    plt.ylabel('Link level')
    plt.savefig(figPath + '/levels/' + str(scheme) + '/' + 'total' + '_' + str(direction) + '_' + color + '.pdf', bbox_inches='tight')
    plt.close()

    # plot all nodes normalised to usage of first level
    usages = usageLevelsNorm.transpose()
    plt.figure(figsize=(11, 3))
    ax = plt.subplot()
    plt.pcolormesh(usages[:, loadOrder], cmap=cmap)
    plt.colorbar().set_label(label=r'$U_n^{(l)}$', size=11)
    ax.set_yticks(np.linspace(.5, levels - .5, levels))
    ax.set_yticklabels(range(1, levels + 1))
    ax.yaxis.set_tick_params(width=0)
    ax.xaxis.set_tick_params(width=0)
    ax.set_xticks(np.linspace(1, nodes, nodes))
    ax.set_xticklabels(loadNames, rotation=60, ha="right", va="top", fontsize=10)
    plt.ylabel('Link level')
    plt.savefig(figPath + '/levels/' + str(scheme) + '/' + 'total_norm_cont_' + str(direction) + '_' + color + '.pdf', bbox_inches='tight')
    plt.close()
开发者ID:asadashfaq,项目名称:FlowcolouringA,代码行数:60,代码来源:vector.py

示例4: serve_css

def serve_css(name, length, keys, values):
    from pylab import plt, mpl
    mpl.rcParams['font.sans-serif'] = ['SimHei']
    mpl.rcParams['axes.unicode_minus'] = False
    from matplotlib.font_manager import FontProperties
    # font = FontProperties(fname="d:\Users\ll.tong\Desktop\msyh.ttf", size=12)
    font = FontProperties(fname="/usr/share/fonts/msyh.ttf", size=11)
    plt.xlabel(u'')
    plt.ylabel(u'出现次数',fontproperties=font)
    plt.title(u'词频统计',fontproperties=font)
    plt.grid()
    keys = keys.decode("utf-8").split(' ')
    values = values.split(' ')
    valuesInt = []
    for value in values:
        valuesInt.append(int(value))

    plt.xticks(range(int(length)), keys)
    plt.plot(range(int(length)), valuesInt)
    plt.xticks(rotation=defaultrotation, fontsize=9,fontproperties=font)
    plt.yticks(fontsize=10,fontproperties=font)
    name = name + str(datetime.now().date()).replace(':', '') + '.png'
    imgUrl = 'static/temp/' + name
    fig = matplotlib.pyplot.gcf()
    fig.set_size_inches(12.2, 2)
    plt.savefig(imgUrl, bbox_inches='tight', figsize=(20,4), dpi=100)
    plt.close()
    tempfile = static_file(name, root='./static/temp/')
    #os.remove(imgUrl)
    return tempfile
开发者ID:tonglanli,项目名称:jiebademo,代码行数:30,代码来源:wsgi.py

示例5: render_confusion

def render_confusion(file_name, queue, vmin, vmax, divergent, array_shape):
    from pylab import plt
    import matplotlib.animation as animation
    plt.close()
    fig = plt.figure()

    def update_img((expected, output)):
        plt.cla()
        plt.ylim((vmin, vmin+vmax))
        plt.xlim((vmin, vmin+vmax))
        ax = fig.add_subplot(111)
        plt.plot([vmin, vmin+vmax], [vmin, vmin+vmax])
        ax.grid(True)
        plt.xlabel("expected output")
        plt.ylabel("network output")
        plt.legend()

        expected = expected*vmax + vmin
        output = output*vmax + vmin
        #scat.set_offsets((expected, output))
        scat = ax.scatter(expected, output)
        return scat

    ani = animation.FuncAnimation(fig, update_img, frames=IterableQueue(queue))

    ani.save(file_name, fps=30, extra_args=['-vcodec', 'libvpx', '-threads', '4', '-b:v', '1M'])
开发者ID:schreon,项目名称:neuronaut-tests,代码行数:26,代码来源:neuronaut_plot.py

示例6: test_plot_dep_contour

 def test_plot_dep_contour(self):
     plot = MapPlotSlab()
     plot.plot_dep_contour(-20, color='red')
     plot.plot_dep_contour(-40, color='blue')
     plot.plot_dep_contour(-60, color='black')
     plt.savefig(join(this_test_path, '~outs/plot_dep_contour.png'))
     plt.close()
开发者ID:zy31415,项目名称:viscojapan,代码行数:7,代码来源:test_map_plot_slab.py

示例7: plot

    def plot(cls, data, figure_folder, msg="", suffix=""):

        fig, ax = plt.subplots()

        plt.subplots_adjust(left=0.1, right=0.9, top=0.9, bottom=0.2)

        x = np.arange(len(data[:]))

        ax.plot(x, data[:, 0], c="red", linewidth=2, label="agent 01")
        ax.plot(x, data[:, 1], c="blue", linewidth=2, label="agent 12")
        ax.plot(x, data[:, 2], c="green", linewidth=2, label="agent 20")

        plt.ylim([-0.01, 1.01])

        plt.text(0, -0.23, "PARAMETERS. {}".format(msg))

        ax.legend(fontsize=12, bbox_to_anchor=(1.1, 1.05))  # loc='upper center'
        ax.set_xlabel("$t$")
        ax.set_ylabel("Proportion of agents proceeding to indirect exchange")

        ax.set_title("Money emergence with a basal ganglia model")

        # Save fig
        if not exists(figure_folder):
            mkdir(figure_folder)
        fig_name = "{}/figure_{}.pdf".format(figure_folder, suffix.split(".p")[0])
        plt.savefig(fig_name)
        plt.close()
开发者ID:AurelienNioche,项目名称:EconomicsBasalGanglia,代码行数:28,代码来源:analysis.py

示例8: test1

    def test1(self):
        partition_file = '/home/zy/workspace/viscojapan/tests/share/deformation_partition.h5'
        res_file = '/home/zy/workspace/viscojapan/tests/share/nrough_05_naslip_11.h5'



        plotter = vj.inv.PredictedTimeSeriesPlotter(
            partition_file = partition_file,
            #result_file = res_file,
            )

        site = 'J550'
        cmpt = 'e'
        #plotter.plot_cumu_disp_pred(site, cmpt)
        #plotter.plot_cumu_disp_pred_added(site, cmpt, color='blue')
        # plotter.plot_post_disp_pred_added(site, cmpt)
        #plotter.plot_cumu_obs_linres(site, cmpt)
        #plotter.plot_R_co(site, cmpt)
        # plotter.plot_post_disp_pred(site, cmpt)
        # plotter.plot_post_obs_linres(site, cmpt)
        #plotter.plot_E_cumu_slip(site, cmpt)
        # plotter.plot_E_aslip(site, cmpt)
        #plotter.plot_R_aslip(site, cmpt)
        #plt.show()
        #plt.close()


        #
        plotter.plot_cumu_disp_decomposition(site, cmpt)
        plt.show()
        plt.close()

        plotter.plot_post_disp_decomposition(site, cmpt)
        plt.show()
        plt.close()
开发者ID:zy31415,项目名称:viscojapan,代码行数:35,代码来源:test_plot_predicted_time_series.py

示例9: test_plot_slip

    def test_plot_slip(self):
        ep = EpochalIncrSlip(self.file_incr_slip)

        plot = MapPlotFault(self.file_fault)
        plot.plot_slip(ep(0))

        plt.savefig(join(self.outs_dir, 'plot_slip.png'))
        plt.close()
开发者ID:zy31415,项目名称:viscojapan,代码行数:8,代码来源:test_map_plot_fault.py

示例10: plot_data

 def plot_data(self):
     for i,dat in enumerate(self.data):
         plt.imshow(dat, cmap=cm.jet, interpolation=None, extent=[11,22,-3,2])
         txt='plot '.format(self.n[i])
         txt+='\nmin {0:.2f} und max {1:.2f}'.format(self.min[i],self.max[i])
         txt+='\navg. min {0:.2f} und avg. max {1:.2f}'.format(mean(self.min),mean(self.max))
         plt.suptitle(txt,x=0.5,y=0.98,ha='center',va='top',fontsize=10)
         plt.savefig(join(self.plotpath,'pic_oo_'+str(self.n[i])+'.png'))
         plt.close()  # wichtig, sonst wird in den selben Plot immer mehr reingepackt
开发者ID:antiface,项目名称:tiny_py_oo_primer,代码行数:9,代码来源:process_data_oo.py

示例11: plot_post

def plot_post(cfs,ifshow=False,loc=2,
              save_fig_path = None, file_type='png'):
    for cf in cfs:
        plot_cf(cf, color='blue')
        plt.legend(loc=loc)
        if ifshow:
            plt.show()
        if save_fig_path is not None:
            plt.savefig(join(save_fig_path, '%s_%s.%s'%(cf.SITE, cf.CMPT, file_type)))
        plt.close()
开发者ID:zy31415,项目名称:viscojapan,代码行数:10,代码来源:plot_post.py

示例12: plot_mat

 def plot_mat(self, mat, fn):
     plt.matshow(asarray(mat.todense()))
     plt.axis('equal')
     sh = mat.shape
     plt.gca().set_yticks(range(0,sh[0]))
     plt.gca().set_xticks(range(0,sh[1]))
     plt.grid('on')
     plt.colorbar()
     plt.savefig(join(self.outs_dir, fn))
     plt.close()
开发者ID:zy31415,项目名称:viscojapan,代码行数:10,代码来源:test_regularization.py

示例13: test_dip

 def test_dip(self):
     xf = arange(0, 425)
     dips = self.fm.get_dip(xf)
     plt.plot(xf,dips)
     plt.grid('on')
     plt.gca().set_xticks(self.fm.Y_PC)
     plt.ylim([0, 30])
     plt.gca().invert_yaxis()
     plt.savefig(join(self.outs_dir, '~y_fc_dips.png'))
     plt.close()
开发者ID:zy31415,项目名称:viscojapan,代码行数:10,代码来源:test_fault_framework.py

示例14: test_pcolor_on_fault

    def test_pcolor_on_fault(self):
        ep = EpochalIncrSlip(self.file_incr_slip)
        fio = FaultFileIO(self.file_fault)

        slip = ep(0).reshape([fio.num_subflt_along_dip,
                              fio.num_subflt_along_strike])

        plot = MapPlotFault(self.file_fault)
        plot.pcolor_on_fault(slip)
        plt.savefig(join(self.outs_dir, 'pcolor_on_fault.png'))
        plt.close()
开发者ID:zy31415,项目名称:viscojapan,代码行数:11,代码来源:test_map_plot_fault.py

示例15: test_share_basemap

    def test_share_basemap(self):
        bm = MyBasemap(x_interval = 1)

        p1 = MapPlotSlab(basemap = bm)
        p1.plot_top()
        
        p2 = MapPlotFault(fault_file=join(this_script_dir, 'share/fault.h5'),
                          basemap = bm)
        p2.plot_fault()

        plt.savefig(join(this_script_dir, '~outs/share_basemap.png'))
        plt.close()
开发者ID:zy31415,项目名称:viscojapan,代码行数:12,代码来源:test_my_base_map.py


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