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


Python matplotlib2tikz.tikz_save函数代码示例

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


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

示例1: compplot_deviations

def compplot_deviations(jsonfilelist, fignum=333, figname="figdiff", compress=10):
    """ compute the deviations of the measured output from the stable

    state output
    """

    import matplotlib.cm as cm

    fig = plt.figure(fignum)
    ax1 = fig.add_subplot(111)
    diffnormlist = []
    collin = np.linspace(0.2, 0.7, len(jsonfilelist))

    for k, jsfstr in enumerate(jsonfilelist):
        jsf = dou.load_json_dicts(jsfstr)
        tmesh = jsf["tmesh"]
        redinds = range(0, len(tmesh), compress)
        redina = np.array(redinds)
        outsig = np.array(jsf["outsig"])
        # two norm at the differences
        outsigdiff = np.sqrt(((outsig - outsig[0, :]) * (outsig - outsig[0, :])).sum(axis=1))
        diffnormlist.append((tmesh[-1] - tmesh[0]) / len(tmesh) * outsigdiff.sum())
        curline, = ax1.plot(
            np.array(tmesh)[redina], outsigdiff[redina], c=cm.CMRmap(collin[k]), linewidth=2.0, label="{0}".format(k)
        )

    handles, labels = ax1.get_legend_handles_labels()
    ax1.legend(handles, labels, loc="lower right")

    tikz_save(figname + "{0}".format(fignum) + ".tikz", figureheight="\\figureheight", figurewidth="\\figurewidth")
    print "saved to " + figname + "{0}".format(fignum) + ".tikz"
    fig.show()
    print diffnormlist
    print len(tmesh)
开发者ID:highlando,项目名称:lqgbt-oseen,代码行数:34,代码来源:pltdatascompare.py

示例2: save_records_plot

def save_records_plot(file_path, ls_monitors, name, n_train_batches, legend_loc="upper right"):
    """
    Save a plot of a list of monitors' history.
    Args:
        file_path (string): the folder path where to save the plot
        ls_monitors: the list of statistics to plot
        name: name of file to be saved
        n_train_batches: the total number of training batches
    """

    lines = ["--", "-", "-.",":"]
    linecycler = cycle(lines)

    plt.figure()
    for m in ls_monitors:
        X = [i/float(n_train_batches) for i in m.history_minibatch]
        Y = m.history_value
        a, b = zip(*sorted(zip(X, Y)))
        plt.plot(a, b, next(linecycler), label=m.name)

    plt.xlabel('Training epoch')
    plt.ylabel(ls_monitors[0].type)
    plt.legend(loc=legend_loc)
    plt.locator_params(axis='y', nbins=7)
    plt.locator_params(axis='x', nbins=10)
    plt.savefig(file_path + name + ".png")
    tikz_save(file_path + name + ".tikz", figureheight = '\\figureheighttik', figurewidth = '\\figurewidthtik')
开发者ID:adbrebs,项目名称:spynet,代码行数:27,代码来源:monitor.py

示例3: f_conv_plot

def f_conv_plot(fval_0sr1, fval_prox_grad):
    """
    
    """
    
    import matplotlib.pyplot as plt
    from matplotlib2tikz import save as tikz_save
    
    fval_0sr1.insert(0, f(x0))
    fval_prox_grad.insert(0, f(x0))
    fval_l_bfgs_b.insert(0, f_l_bfgs_b(x0_l_bfgs_b))
    fval_l_bfgs_b.insert(0, f_l_bfgs_b(x0_l_bfgs_b))
    
    line1, = plt.plot(range(len(fval_0sr1)), fval_0sr1, 'r', label = '0SR1', lw = 2)
    line2, = plt.plot(range(len(fval_prox_grad)), fval_prox_grad, 'b', label = 'ProxGrad', lw = 2)
    line3, = plt.plot(range(len(fval_l_bfgs_b)), fval_l_bfgs_b, 'g', label = 'L-BFGS-B', lw = 2)
    #plt.xscale('log')
    #plt.xlim([0, 1e2])
    plt.yscale('log')
    #plt.ylim([0, 1e5])
    plt.ylabel('Function Value')
    plt.xlabel('Number of Iterations')
    plt.legend(handles = [line1, line2, line3])
    tikz_save( 'ProxPDE.tikz' );
    plt.show()
    
    return
开发者ID:heidekrueger,项目名称:CaseStudiesMachineLearning,代码行数:27,代码来源:ProxTest_PDE.py

示例4: save_plot

 def save_plot(self, argument=None, name='plot', path='images/', **kwargs):
     from matplotlib2tikz import save as tikz_save
     directory = path
     if not os.path.isdir(directory):
         os.makedirs(directory)
     plot = self.plot(argument, **kwargs)
     info = plot['info']
     proj_3d = False
     for k, _ in enumerate(info):
         for l, _ in enumerate(info[0]):
             if ('projection' in info[k][l] and
                     info[k][l]['projection'] == '3d'):
                 proj_3d = True
     if proj_3d:
         warnings.warn('3D plotting is not supported by matplotlib2tikz. ' +
                       'Saving to pdf instead.')
         path = directory+'/'+name+'.pdf'
         plt.savefig(path, bbox_inches='tight', pad_inches=0)
     else:
         figurewidth = kwargs[
             'figurewidth'] if 'figurewidth' in kwargs else '8cm'
         figureheight = kwargs[
             'figureheight'] if 'figureheight' in kwargs else None
         path = directory+'/'+name+'.tikz'
         if figureheight is None:
             tikz_save(path, figurewidth=figurewidth)
         else:
             tikz_save(
                 path, figurewidth=figurewidth, figureheight=figureheight)
         _cleanup_rubbish(path, info)
开发者ID:meco-group,项目名称:omg-tools,代码行数:30,代码来源:plotlayer.py

示例5: save_tex

def save_tex(filename, **kwargs):
    """
    Save figure created with script 'filename' to a tex file using
    matplotlib2tikz. Output directory is figures/. You can specify a
    subdirectory using the 'subdir' kwarg.
    Valid kwargs: addFigureDims and anything passed to matplotlib2tikz.save().
    figureheight and -width variables will be added if addFigureDims is true.
    Pass a 'suffix' if you generate multiple plots from one script.

    :param  filename | __file__ of the plotting script
            addFigureDims | bool
    """
    from matplotlib2tikz import save as tikz_save
    import os.path
    addFigureDims = kwargs.pop("addFigureDims", False)
    kwargs["figurewidth"] = '\\figurewidth' if addFigureDims else None
    kwargs["figureheight"] = '\\figureheight' if addFigureDims else None
    suffix = kwargs.pop("suffix", "")
    subdir = kwargs.pop("subdir", "")
    kwargs["tex_relative_path_to_data"] = os.path.join("figures", subdir)
    if len(subdir):
        subdir += os.path.sep
    tikz_save(
            '../figures/{}{}{}.tex'.format(
                subdir,
                os.path.basename(filename).split('.')[0],
                suffix),
            **kwargs)
开发者ID:pylipp,项目名称:mscthesis,代码行数:28,代码来源:utils.py

示例6: save_movie

 def save_movie(self, signal, name='movie', path='movies/', **kwargs):
     from matplotlib2tikz import save as tikz_save
     directory = path + name
     if not os.path.isdir(directory):
         os.makedirs(directory)
     t = self.vehicles[0].signals['time']
     if ('number_of_frames' in kwargs and
             kwargs['number_of_frames'] <= (t.shape[1]-1)):
         number_of_frames = kwargs['number_of_frames']
     else:
         number_of_frames = t.shape[1]-1
     root = kwargs['root'] if 'root' in kwargs else None
     figurewidth = kwargs['figurewidth'] if 'figurewidth' in kwargs else '8cm'
     figureheight = kwargs['figureheight'] if 'figureheight' in kwargs else None
     subsample = (t.shape[1]-2)/(number_of_frames-1)
     kwargs['no_update'] = True
     plot = self.show(signal, **kwargs)
     cnt = 0
     for k in range(0, t.shape[1]-1, subsample):
         self.update(k, plots=plot)
         if signal == 'scene':
             plt.axis('off')
         path = directory+'/'+name+'_'+str(cnt)+'.tikz'
         if figureheight is None:
             tikz_save(path, figurewidth=figurewidth)
         else:
             tikz_save(path, figurewidth=figurewidth, figureheight=figureheight)
         self._cleanup_rubbish(path, root)
         cnt += 1
开发者ID:jgillis,项目名称:omg-tools,代码行数:29,代码来源:plots.py

示例7: compplotfreqresps

def compplotfreqresps(jsonfilelist, fignum=444, figname="freqfigdiff", compress=1):
    """ plot the errors in the freqresp for various configurations

    Parameters:
    -----------
    jsonfilelist : list
        of json files as produced by `btu.compare_freqresp`
    """
    import matplotlib.cm as cm

    fig = plt.figure(fignum)
    ax1 = fig.add_subplot(111)
    collin = np.linspace(0.2, 0.7, len(jsonfilelist))

    for k, jsfstr in enumerate(jsonfilelist):
        jsf = dou.load_json_dicts(jsfstr)
        tmesh = jsf["tmesh"]
        redinds = range(0, len(tmesh), compress)
        redina = np.array(redinds)
        outsig = np.array(jsf["diffsysfr"])
        curline, = ax1.plot(
            np.array(tmesh)[redina], outsig[redina], c=cm.CMRmap(collin[k]), linewidth=2.0, label="{0}".format(k)
        )

    handles, labels = ax1.get_legend_handles_labels()
    ax1.legend(handles, labels, loc="lower left")

    tikz_save(figname + "{0}".format(fignum) + ".tikz", figureheight="\\figureheight", figurewidth="\\figurewidth")

    print "saved to " + figname + "{0}".format(fignum) + ".tikz"
    ax1.semilogx()
    ax1.semilogy()
    fig.show()
开发者ID:highlando,项目名称:lqgbt-oseen,代码行数:33,代码来源:pltdatascompare.py

示例8: prox_comparison

def prox_comparison():
    
    import matplotlib.pyplot as plt
    import StochProxGrad as spg
    import StochProxMeth as spm
    import ProxMeth as pm
    import ProxGrad as pg
    from matplotlib2tikz import save as tikz_save
    
    fval_pm = pm.compute_0sr1(fn, gfn, x0, l_reg = l, tau = 1 / L, batch_size = batch_size)
    fval_pg = pg.proximal_gradient(fn, gfn, x0, 1 / L, l_reg = l, batch_size = batch_size)
    fval_spm = spm.compute_0sr1(f, gf, x0, X, y, l_reg = l, tau = 1 / L, batch_size = batch_size)
    fval_spg = spg.proximal_gradient(f, gf, x0, 1 / L, X, y, l_reg = l, batch_size = batch_size)
    fval_pm.insert(0, f(x0, X, y))
    fval_pg.insert(0, f(x0, X, y))
    fval_spm.insert(0, f(x0, X, y))
    fval_spg.insert(0, f(x0, X, y))
    
    line1, = plt.plot(range(len(fval_pm)), fval_pm, 'r', label = '0SR1', lw = 2)
    line2, = plt.plot(range(len(fval_pg)), fval_pg, 'b', label = 'PG', lw = 2)
    line3, = plt.plot(range(len(fval_spm)), fval_spm, 'g', label = 'S0SR1', lw = 2)
    line4, = plt.plot(range(len(fval_spg)), fval_spg, 'k', label = 'SPG', lw = 2)
    
    
    #plt.xlim([0, 55])
    plt.yscale('log')
    #plt.ylim([1e1, 1e13])
    plt.ylabel('Function Value')
    plt.xlabel('Number of Iterations')
    plt.legend(handles = [line1, line2, line3, line4])
    tikz_save( 'StochProx_150.tikz' );

    return
开发者ID:heidekrueger,项目名称:CaseStudiesMachineLearning,代码行数:33,代码来源:StochProxTest_Normal1.py

示例9: perf_profile

def perf_profile():

    erreur_abs=[0,2,5,10,15,20,25]  #erreur relative!
    wpp1=[91.8,91.8,95.9,100,100,100,100]
    wpp2=[95.9,95.9,97.9,100,100,100,100]
    #wpp3=[]
    #dsatur1=[93.1,93.1,93.1,96.5,96.5,100,100]
    dsatur2=[97.9,97.9,97.9,100,100,100,100]
    #szekeres=[89.6,89.6,93.1,96.5,96.5,100,100]
    #rlf1=[93.1,93.1,93.1,96.5,96.5,100,100]
    rlf2=[97.9,97.9,97.9,100,100,100,100]
    
    
    plt.xlim(-0.2,15)
    plt.ylim(87,102)
    plt.xlabel("Relative error compared to optimal solution")
    plt.ylabel("Proportion of tests solved")
    plt.title("Performance profile, |V|=25")

    plot1,=plt.plot(erreur_abs,wpp1,'^-',color='0.3')
    plot2,=plt.plot(erreur_abs,wpp2,'s-',color='0.3')
    #plot3,=plt.plot(erreur_abs,dsatur1,'o--',color='g')
    plot4,=plt.plot(erreur_abs,dsatur2,'v-',color='0.3')
    #plot5,=plt.plot(erreur_abs,szekeres,'v--',color='y')
    #plot6,=plt.plot(erreur_abs,rlf1,'<--',color='c')
    plot7,=plt.plot(erreur_abs,rlf2,'s-',color='0.3')

    plt.legend([plot1,plot2,plot4,plot7],
               ["WP1","WP2","DSAT","RLF"],loc="lower right")
    
    tikz_save('/Users/romainmontagne/Desktop/Projet/article/article v3/perf_profile2.tikz',
           figureheight = '\\figureheight',
           figurewidth = '\\figurewidth')
开发者ID:Kuifje02,项目名称:PDWICP,代码行数:33,代码来源:plots.py

示例10: saveTikzPng

def saveTikzPng(filename, watermark=None, thesis=False, show=False):
    if watermark is not None:
        plt.gcf().text(0.125, 0.9, watermark, fontsize=8)
    filename_png = filename + '.png'
    filename_pdf = filename + '.pdf'
    fig = plt.gcf()
    # plt.plot()
    d = os.getcwd()
    figure_folder = os.path.join(d, 'figures')
    tex_folder = os.path.join(d, 'tex')
    if not os.path.exists(tex_folder):
        os.makedirs(tex_folder)
    if not os.path.exists(figure_folder):
        os.makedirs(figure_folder)
    tikz_save(
        tex_folder + "/" + filename + '.tex',
        figureheight='\\figureheight',
        figurewidth='\\figurewidth'
    )
    if thesis == False:
        fig.savefig(figure_folder + "/" + filename_png,
                    format='png', dpi=600, bbox_inches='tight')
    else:
        fig.savefig(figure_folder + "/" + filename_pdf,
                    format='pdf', dpi=600, bbox_inches='tight')
        fig.savefig(figure_folder + "/" + filename_png,
                    format='png', dpi=600, bbox_inches='tight')         
    if show == True:
        plt.show()
开发者ID:DavidRobertQuinn,项目名称:IV,代码行数:29,代码来源:data_extractor.py

示例11: BarPlot

def BarPlot(
    figName,
    fun0,
    funOpt,
    funLabel0,
    funLabelOpt,
    xLabel,
    yLabel,
    ResultsFolder,
    OptName,
    figType=FileTypeRendered,
    Color0="#FAA43A",
    ColorOpt="#5DA5DA",
    figsizex=6,
    figsizey=3,
    width=0.5,
    xspacing=0.25,
    dpi=200,
    xtick=True,
    usetex=False,
    Tikz=False,
):
    plt.rc("text", usetex=usetex)
    Plot = plt.figure(figsize=(figsizex, figsizey), dpi=dpi)
    ax = Plot.add_subplot(111)
    nf = np.size(fun0)
    ind = np.arange(nf)
    rects1 = ax.bar(ind + xspacing * 2.5, fun0, width, color=Color0)
    rects2 = ax.bar(ind + xspacing * 2.5 + width / 2, funOpt, width, color=ColorOpt)
    lgd = ax.legend(
        (rects1[0], rects2[0]),
        (funLabel0, funLabelOpt),
        frameon=False,
        prop=fontP,
        bbox_to_anchor=(1.05, 1),
        loc=2,
        borderaxespad=0.0,
    )
    ax.spines["right"].set_visible(False)
    ax.spines["top"].set_visible(False)
    ax.yaxis.set_ticks_position("left")
    ax.xaxis.set_ticks_position("bottom")
    ax.xaxis.set_major_locator(ticker.MaxNLocator(integer=True))
    plt.xlim(xmin=xspacing * 2, xmax=nf + width / 2 + xspacing)
    plt.ylim(ymin=np.min((np.min(fun0), np.min(funOpt), 0.0)), ymax=np.max((np.max(fun0), np.max(funOpt))))
    if xtick == False:
        plt.tick_params(axis="x", which="both", bottom="off", labelbottom="off")
    plt.xlabel(xLabel)
    plt.ylabel(yLabel)
    plt.tight_layout()
    for ii in range(np.size(figType)):
        plt.savefig(
            ResultsFolder + OptName + "_" + figName + "." + figType[ii], bbox_extra_artists=(lgd,), bbox_inches="tight"
        )
    if Tikz == True:
        tikz_save(ResultsFolder + OptName + "_" + figName + ".tikz")
    plt.close()
    fail = 0
    return fail
开发者ID:LordTofu,项目名称:DesOptPy,代码行数:59,代码来源:OptResultReport.py

示例12: SingleConvPlot

def SingleConvPlot(
    figName,
    data,
    dataLabel,
    xLabel,
    yLabel,
    ResultsFolder,
    OptName,
    figType=FileTypeRendered,
    figsizex=6,
    figsizey=3,
    width=0.5,
    xspacing=0.25,
    dpi=200,
    xtick=True,
    usetex=False,
    Tikz=False,
    labelSubscripts=True,
):
    plt.rc("text", usetex=usetex)
    Plot = plt.figure(figsize=(figsizex, figsizey), dpi=dpi)
    ax = Plot.add_subplot(111)
    jet = plt.get_cmap("jet")
    cNorm = colors.Normalize(vmin=0, vmax=len(data[0]))
    scalarMap = cm.ScalarMappable(norm=cNorm, cmap=jet)
    for n in range(np.size(data[0])):
        if labelSubscripts == True:
            if usetex == True:
                ax.plot(data[:, n], color=scalarMap.to_rgba(n), label=dataLabel % str(n + 1))
            else:
                ax.plot(data[:, n], color=scalarMap.to_rgba(n), label=dataLabel % str(n + 1))
        else:
            ax.plot(data[:, n], color=scalarMap.to_rgba(n), label=dataLabel)
    plt.xlabel(xLabel)
    plt.ylabel(yLabel)
    plt.xlim(xmin=0, xmax=len(data) - 1)
    ax.spines["right"].set_visible(False)
    ax.spines["top"].set_visible(False)
    ax.yaxis.set_ticks_position("left")
    ax.xaxis.set_ticks_position("bottom")
    ax.xaxis.set_major_locator(ticker.MaxNLocator(integer=True))
    numColx = (np.size(data[0]) / 12) + 1
    if numColx > 3:
        numColx = 3
    plt.yticks(size=10 + (numColx - 1) * 4)
    lgd = ax.legend(bbox_to_anchor=[1.05, 1], loc=2, ncol=numColx, frameon=False, prop=fontPP)
    plt.tight_layout()
    for ii in range(np.size(figType)):
        plt.savefig(
            ResultsFolder + OptName + "_" + figName + "." + figType[ii], bbox_extra_artists=(lgd,), bbox_inches="tight"
        )
    if Tikz == True:
        tikz_save(ResultsFolder + OptName + "_" + figName + ".tikz")
    plt.close()
    fail = 0
    return fail
开发者ID:LordTofu,项目名称:DesOptPy,代码行数:56,代码来源:OptResultReport.py

示例13: graph

def graph(datamodel, target_list, selected_metrics, name_replace_list):
    
    xdata = []
    ydata = []
    for i, target in enumerate(target_list):
        # Read data and initialize data model
        f = open(target, 'r')
        target_data = datamodel(f.read())
        if i == 0:
            # On first pass, create header list
            first = target_data
            if selected_metrics is None:
                metrics = target_data.get_all_titles()
            else:
                metrics = target_data.get_title_list(selected_metrics)
        else:
            # On subsequent passes, ensure they all have the same metrics and titles
            first.check_titles_match(target_data)

        # Perform find/replace on filename
        target_name = target
        for (fstr, rstr) in name_replace_list:
            target_name = target_name.replace(fstr, rstr)
        xdata.append(target_name)

        # Append all the data
        if selected_metrics is None:
            ydata.append(target_data.get_all_data())
        else:
            ydata.append(target_data.get_data_list(selected_metrics))
    
    ydata = transpose(ydata)
    # Create graph
    fig = plt.figure()
    x = range(len(xdata))

    for i, metric in enumerate(metrics):
        plt.plot(x, ydata[i], 'o-', lw=4.0, label=metric)

    # Set temporary x-axis to text xdata
    plt.xticks(x, xdata)
    plt.legend(loc='lower right', bbox_to_anchor=(0.5, -0.05))
    
    # Write to a temporary file, 
    filename = "graph.tmp"
    tikz_save(filename)
    plt.close(fig)
    # get the string from that file,
    f = open(filename, 'r')
    graph_data = f.read()
    # remove the file,
    f.close()
    os.remove(filename)
    # then return the string
    return graph_data
开发者ID:fubuloubu,项目名称:GuitarView,代码行数:55,代码来源:print_data_model.py

示例14: plot

def plot(name, qualities_mes, costs_mes, qualities_th, costs_th):
    fig, axes = plt.subplots(2,1)

    ax1= axes[0]

    texts_mes= []
    for (i, (quality, cost)) in enumerate(zip(qualities_mes, costs_mes)):
        texts_mes.append(ax1.text(quality, cost, str(i), ha='center', va='center'))

    #print("Measured: ", q, c_cycle)

    color='tab:red'

    ax1.set_ylabel("cost per cycle (µs)")
    ax1.set_xlabel("quality")
    ax1.scatter(qualities_mes, costs_mes,  label="Measured", color=color)
    ax1.tick_params(axis='y', labelcolor=color)
    ax1.grid(True)

    ax2 = axes[1]

    texts_th = []
    for (i, (quality, cost)) in enumerate(zip(qualities_th, costs_th)):
        texts_th.append(ax2.text(quality, cost, str(i), ha='center', va='center'))

    color = 'tab:blue'
    ax2.set_ylabel("cost")
    ax2.set_xlabel("quality")

    ax2.scatter(qualities_th, costs_th,  label="Model", color=color)
    ax2.tick_params(axis='y', labelcolor=color)
    ax2.grid(True)


    adjust_text(texts_mes, ax=ax1)
    adjust_text(texts_th, ax=ax2)

    kendalltau = GraphResults("Kendall's tau")
    kendalltau.costs = stats.kendalltau(costs_mes, costs_th, nan_policy='raise')
    kendalltau.quality = stats.kendalltau(qualities_mes, qualities_th, nan_policy='raise')

    spearmanr = GraphResults("Spearman's R")
    spearmanr.costs = stats.spearmanr(costs_mes, costs_th, nan_policy='raise')
    spearmanr.quality = stats.spearmanr(qualities_mes, qualities_th, nan_policy='raise')

    print(kendalltau.name, " Kendal's tau: cost=", kendalltau.costs, " and quality=", kendalltau.quality)
    print(spearmanr.name, " Spearman's r: cost=", spearmanr.costs, " and quality=", spearmanr.quality)


    fig.tight_layout()
    fig.legend()
    if args.tikz:
        tikz_save(name+".tex")
    plt.show()
开发者ID:programLyrique,项目名称:audio-adaptive-scheduling,代码行数:54,代码来源:pipeline.py

示例15: plot_outp_sig

def plot_outp_sig(str_to_json=None, tmeshkey='tmesh', sigkey='outsig',
                  outsig=None, tmesh=None, fignum=222, reference=None,
                  tikzstr=None, compress=5, notikz=False):
    import matplotlib.pyplot as plt

    if str_to_json is not None:
        jsdict = load_json_dicts(str_to_json)
        tmesh = jsdict[tmeshkey]
        outsig = jsdict[sigkey]
    else:
        str_to_json = 'notspecified'

    redinds = list(range(1, len(tmesh), compress))
    redina = np.array(redinds)

    NY = np.int(len(outsig[0])/2)

    fig = plt.figure(fignum)
    ax1 = fig.add_subplot(111)
    ax1.plot(np.array(tmesh)[redina], np.array(outsig)[redina, :NY],
             color='b', linewidth=2.0)
    ax1.plot(np.array(tmesh)[redina], np.array(outsig)[redina, NY:],
             color='r', linewidth=2.0)
    if notikz:
        plt.show()
        return

    try:
        from matplotlib2tikz import save as tikz_save
        if tikzstr is None:
            tikzstr = str_to_json + '{0}'.format(fignum)
        tikz_save(tikzstr + '.tikz',
                  figureheight='\\figureheight',
                  figurewidth='\\figurewidth'
                  )
        print('tikz saved to ' + tikzstr + '.tikz')
        haztikz = True
    except ImportError:
        haztikz = False
        print('cannot save to tikz -- no matplotlib2tikz found')

    fig.show()

    if reference is not None:
        fig = plt.figure(fignum+1)
        ax1 = fig.add_subplot(111)
        ax1.plot(tmesh, np.array(outsig)-reference)

        if haztikz:
            tikz_save(str_to_json + '{0}'.format(fignum) + '_difftoref.tikz',
                      figureheight='\\figureheight',
                      figurewidth='\\figurewidth'
                      )
        fig.show()
开发者ID:highlando,项目名称:dolfin_navier_scipy,代码行数:54,代码来源:data_output_utils.py


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