• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python plt.savefig函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



在下文中一共展示了savefig函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: 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


示例3: draw

    def draw(cls, t_max, agents_proportions, eco_idx, parameters):

        color_set = ["green", "blue", "red"]

        for agent_type in range(3):
            plt.plot(np.arange(t_max), agents_proportions[:, agent_type],
                     color=color_set[agent_type], linewidth=2.0, label="Type-{} agents".format(agent_type))

            plt.ylim([-0.1, 1.1])

        plt.xlabel("$t$")
        plt.ylabel("Proportion of indirect exchanges")

        # plt.suptitle('Direct choices proportion per type of agents', fontsize=14, fontweight='bold')
        plt.legend(loc='upper right', fontsize=12)

        print(parameters)

        plt.title(
            "Workforce: {}, {}, {};   displacement area: {};   vision area: {};   alpha: {};   tau: {}\n"
            .format(
                parameters["x0"],
                parameters["x1"],
                parameters["x2"],
                parameters["movement_area"],
                parameters["vision_area"],
                parameters["alpha"],
                parameters["tau"]
                          ), fontsize=12)

        if not path.exists("../../figures"):
            mkdir("../../figures")

        plt.savefig("../../figures/figure_{}.pdf".format(eco_idx))
        plt.show()
开发者ID:AurelienNioche,项目名称:SpatialEconomy,代码行数:35,代码来源:analysis_unique_eco.py


示例4: 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


示例5: 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


示例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_response

def plot_response(data, plate_name, save_folder = 'Figures/'):
    """
    """
    if not os.path.isdir(save_folder):
        os.makedirs(save_folder)

    for block in data:
        #
        group = group_similar(data[block].keys())
        names = data[block].keys()
        names.sort()
        #
        plt.figure(figsize=(16, 4 + len(names)/8), dpi=300)
        #
        for i, name in enumerate(names):
            a, b, c = get_index(group, name)
            color, pattern = color_shade_pattern(a, b, c, group)
            mean = data[block][name]['mean'][0]
            std = data[block][name]['std'][0]

            plt.barh([i], [mean], height=1.0, color=color, hatch=pattern)
            plt.errorbar([mean], [i+0.5], xerr=[std], ecolor = [0,0,0], linestyle = '')

        plt.yticks([i+0.5 for i in xrange(len(names))], names, size = 8)
        plt.title(plate_name)
        plt.ylim(0, len(names))
        plt.xlabel('change')
        plt.tight_layout()

        plt.savefig(save_folder + 'response_' + str(block + 1))
    #
    return None
开发者ID:bozokyzoltan,项目名称:Plate-reader-analitics,代码行数:32,代码来源:plot.py


示例8: 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


示例9: generate_start_time_figures

    def generate_start_time_figures(self):
        recording_time_grouped_by_patient = self.pain_data[["PatientID", "NRSTimeFromEndSurgery_mins"]].groupby("PatientID")
        recording_start_minutes = recording_time_grouped_by_patient.min()

        fig1 = "fig1.pdf"
        fig2 = "fig2.pdf"

        plt.figure(figsize=[8,4])
        plt.title("Pain score recording start times", fontsize=14).set_y(1.05) 
        plt.ylabel("Occurrences", fontsize=14)
        plt.xlabel("Recording Start Time (minutes)", fontsize=14)
        plt.hist(recording_start_minutes.values, bins=20, color="0.5")
        plt.savefig(os.path.join(self.tmp_directory, fig1), bbox_inches="tight")

        plt.figure(figsize=[8,4])
        plt.title("Pain score recording start times, log scale", fontsize=14).set_y(1.05) 
        plt.ylabel("Occurrences", fontsize=14)
        plt.xlabel("Recording Start Time (minutes)", fontsize=14)
        plt.hist(recording_start_minutes.values, bins=20, log=True, color="0.5")
        plt.savefig(os.path.join(self.tmp_directory, fig2), bbox_inches="tight")

        #save the figures in panel format
        f = open(os.path.join(self.tmp_directory, "tmp.tex"), 'w')
        f.write(r"""
            \documentclass[%
            ,float=false % this is the new default and can be left away.
            ,preview=true
            ,class=scrartcl
            ,fontsize=20pt
            ]{standalone}
            \usepackage[active,tightpage]{preview}
            \usepackage{varwidth}
            \usepackage{graphicx}
            \usepackage[justification=centering]{caption}
            \usepackage{subcaption}
            \usepackage[caption=false,font=footnotesize]{subfig}
            \renewcommand{\thesubfigure}{\Alph{subfigure}}
            \begin{document}
            \begin{preview}
            \begin{figure}[h]
                \begin{subfigure}{0.5\textwidth}
                        \includegraphics[width=\textwidth]{""" + fig1 + r"""}
                        \caption{Normal scale}
                \end{subfigure}\begin{subfigure}{0.5\textwidth}
                        \includegraphics[width=\textwidth]{""" + fig2 + r"""}
                        \caption{Log scale}
                \end{subfigure}
            \end{figure}
            \end{preview}
            \end{document}
        """)
        f.close()
        subprocess.call(["pdflatex", 
                            "-halt-on-error", 
                            "-output-directory", 
                            self.tmp_directory, 
                            os.path.join(self.tmp_directory, "tmp.tex")])
        shutil.move(os.path.join(self.tmp_directory, "tmp.pdf"), 
                    os.path.join(self.output_directory, "pain_score_start_times.pdf"))
开发者ID:pvnick,项目名称:tempos,代码行数:59,代码来源:appendix_c.py


示例10: 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


示例11: test_plot

    def test_plot(self):
        res_file = '/home/zy/workspace/viscojapan/tests/share/nrough_05_naslip_11.h5'
        reader = vj.inv.ResultFileReader(res_file)
        slip = reader.get_slip()

        plotter = vj.slip.plot.plot_slip_and_rate_at_subflt(
            slip, 8, 8)

        plt.savefig(join(self.outs_dir, 'slip_and_rate.pdf'))
开发者ID:zy31415,项目名称:viscojapan,代码行数:9,代码来源:test_plot_slip_and_rate_at_subflt.py


示例12: 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


示例13: 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


示例14: 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


示例15: 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


示例16: 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


示例17: 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


示例18: test_fault2geo

    def test_fault2geo(self):
        xf = linspace(0., 700, 25)
        yf = linspace(0, 425, 30)
        xxf, yyf = meshgrid(xf, yf)
        
        LLons, LLats = self.fm.fault2geo(xxf, yyf)

        self.plt_map.basemap.plot(LLons,LLats,color='gray',latlon=True)
        self.plt_map.basemap.plot(ascontiguousarray(LLons.T),
                  ascontiguousarray(LLats.T),
                  color='gray',latlon=True)
        plt.savefig('~test_fault2geo.png')
        plt.close()
开发者ID:zy31415,项目名称:viscojapan,代码行数:13,代码来源:test_fault_coordinates_transformation.py


示例19: test_ground2geo

    def test_ground2geo(self):
        xp = linspace(0, 700, 25)
        yp = linspace(0, 425, 30)
        xxp, yyp = meshgrid(xp, yp)
       
        LLons, LLats = self.fm.ground2geo(xxp, yyp)

        self.plt_map.basemap.plot(LLons,LLats,color='gray',latlon=True)
        self.plt_map.basemap.plot(ascontiguousarray(LLons.T),
                  ascontiguousarray(LLats.T),
                  color='gray',latlon=True)
        plt.savefig('~test_ground2geo.png')
        plt.close()
开发者ID:zy31415,项目名称:viscojapan,代码行数:13,代码来源:test_fault_coordinates_transformation.py


示例20: plot_smoothed_alpha_comparison

 def plot_smoothed_alpha_comparison(self,rmsval,suffix=''):
     plt.plot(self.f,self.alpha,'ko',label='data set')
     plt.plot(self.f,self.salpha,'c-',lw=2,label='smoothed angle $\phi$')
     plt.xlabel('frequency in Hz')
     plt.ylabel('angle $\phi$ in coordinates of circle')
     plt.legend()
     ylims=plt.axes().get_ylim()
     plt.yticks((arange(9)-4)*0.5*pi, ['$-2\pi$','$-3\pi/2$','$-\pi$','$-\pi/2$','$0$','$\pi/2$','$\pi$','$3\pi/2$','$2\pi$'])
     plt.ylim(ylims)
     plt.title('RMS offset from smooth curve: {:.4f}'.format(rmsval))
     if self.show: plt.show()
     else: plt.savefig(join(self.sdc.plotpath,'salpha','c{}_salpha_on_{}_circle'.format(self.sdc.case,self.ZorY)+self.sdc.suffix+self.sdc.outsuffix+suffix+'.png'), dpi=240)
     plt.close()
开发者ID:antiface,项目名称:zycircle,代码行数:13,代码来源:ZYCircle.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python plt.show函数代码示例发布时间:2022-05-25
下一篇:
Python plt.plot函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap