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


Python pyplot.figlegend函数代码示例

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


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

示例1: scatter_plot_matrix

def scatter_plot_matrix(data,class_labels,filename):
    plt.figure(figsize=(2000/96, 2000/96), dpi=96)
    for i in range(0,5):
        plt.subplot(5,5,5*i+i+1)
        plt.title(str(data.columns[i]), fontsize=10)
        min_value = float(np.min(data.ix[:,i]))
        max_value = float(np.max(data.ix[:,i]))
        xs = np.linspace(min_value,max_value,500) 
        k=0
        for cl in class_list:
            ind = np.where(class_labels == cl)[0]
            plot_density(data.ix[ind,i],xs,col[k])
            k+=1
        k=0
        for j in range(0,5):
            if i!=j:
                plt.subplot(5,5,5*i+j+1)
                plt.title(str(data.columns[i]) + " vs " + str(data.columns[j]), fontsize=10)
                plt.xlabel(data.columns[i], fontsize=10)
                plt.ylabel(data.columns[j], fontsize=10)
                for k in range(0,4):
                    ind = np.where(class_labels == class_list[k])[0]
                    plt.scatter(data.ix[ind,i],data.ix[ind,j],s=10,color = col[k],marker = marker_style[k], facecolors = 'none')
    line=[]
    for i in range(0,4):
        line.append(mlines.Line2D([], [], color=col[i], marker=marker_style[i],markersize=10))
    plt.tight_layout()
    plt.figlegend(handles = line, labels = class_list, loc = "upper right")
    plt.savefig(filename)
    plt.show() #refer to the saved image for proper visualization
开发者ID:mnshgl0110,项目名称:Bioinformatics2,代码行数:30,代码来源:task4.py

示例2: plot

def plot(labels, real_values, *values_list):
    values = list(values_list)
    one_step_ahead = []
    one_step_ahead.append(real_values)
    k_step_ahead = []
    k_step_ahead.append(real_values)
    for i in range(0, len(values)/2):
        one_step_ahead.append(values[i])
        k_step_ahead.append(values[len(values)/2 + i])
    observations = []
    for i in np.arange(1, len(real_values) + 1):
        observations.append(i)
    plt.subplot(211)
    plt.grid(True)
    plt.xlabel('observations')
    plt.ylabel('temperature (C)')
    plt.title('One-step-ahead Data Prediction')
    plt.ylim(0, 31)
    lines = []
    for lab, val in zip(labels, one_step_ahead):
        lines.extend(plt.plot(observations, val, label=lab))
    plt.subplot(212)
    plt.grid(True)
    plt.xlabel('observations')
    plt.ylabel('temperature (C)')
    plt.title('K-step-ahead Data Prediction')
    plt.ylim(0, 31)
    for lab, val in zip(labels, k_step_ahead):
        plt.plot(observations, val, label=lab)
    plt.figlegend(lines, labels, loc = 'lower center', ncol=len(labels), labelspacing=0.)
    plt.show()
开发者ID:AleDanish,项目名称:regression,代码行数:31,代码来源:utils.py

示例3: overlay_raw_data

def overlay_raw_data(raw_dict, individual_raw_dict, mole_graph, individual_graph, sun_results, uuid, out_path):
    # used because the SUN model uses single letter labels
    para_map = {"Notch2NL-A": "A", "Notch2NL-B": "B", "Notch2NL-C": "C", "Notch2NL-D": "D", "Notch2": "N"}
    fig, plots = plt.subplots(len(mole_graph.paralogs), sharey=True, figsize=(12.0, 5.0))
    individual_patch = matplotlib.patches.Patch(color=color_palette[0], fill="true")
    mole_patch = matplotlib.patches.Patch(color=color_palette[1], fill="true")
    plt.figlegend((individual_patch, mole_patch), ("Individual", "Mole"), loc='upper right', ncol=2)
    max_gap = max(stop - start for start, stop in mole_graph.paralogs.itervalues())
    for i, (p, para) in enumerate(izip(plots, mole_graph.paralogs.iterkeys())):
        start, stop = mole_graph.paralogs[para]
        rounded_max_gap = int(math.ceil(1.0 * max_gap / 10000) * 10000)
        p.axis([start, start + rounded_max_gap, 0, 4])
        x_ticks = [start] + range(start + 20000, start + rounded_max_gap + 20000, 20000)
        p.axes.set_yticks(range(5))
        p.axes.set_yticklabels(map(str, range(5)), fontsize=9)
        p.axes.set_xticks(x_ticks)
        p.axes.set_xticklabels(["{:.3e}".format(start)] + [str(20000 * x) for x in xrange(1, len(x_ticks))])
        starts, stops, vals = zip(*raw_dict[para])
        p.hlines(vals, starts, stops, color=color_palette[1], alpha=0.8, linewidth=2.0)
        if len(sun_results[para_map[para]]) > 0:
            sun_pos, sun_vals = zip(*sun_results[para_map[para]])
            p.vlines(np.asarray(sun_pos), np.zeros(len(sun_pos)), sun_vals, color="#E83535", linewidth=0.5, alpha=0.5)
        for x in range(1, 4):
            p.axhline(y=x, ls="--", lw=0.5)
        p.set_title("{}".format(para))
    for i, (p, para) in enumerate(izip(plots, individual_graph.paralogs.iterkeys())):
        starts, stops, vals = zip(*individual_raw_dict[para])
        p.hlines(vals, starts, stops, color=color_palette[0], alpha=0.8, linewidth=2.0)
        p.set_title("{}".format(para))    
    fig.subplots_adjust(hspace=0.8)
    plt.savefig(out_path, format="png", dpi=500)
    plt.close()
开发者ID:ifiddes,项目名称:notch2nl_CNV,代码行数:32,代码来源:overlay_raw_data_v2.py

示例4: compare_hr_run

def compare_hr_run(filename1, filename2, descriptor1='1st HR',
                   descriptor2='2nd HR', verbose=False):
  """
  Method to generate a plot comparison between two gpx runs
  """
  import matplotlib.pyplot as plt
  run1 = GPXCardio(filename1, verbose)
  run2 = GPXCardio(filename2, verbose)
  cardio1 = run1.getCardio()
  cardio2 = run2.getCardio()

  # Assume 1st file goes first in time
  def pts_fun(it, hr):
    t = map(lambda x: (x[0] - it).seconds, hr)
    hr = map(lambda x: x[1], hr)
    return t, hr

  initial_time = cardio1[0][0]
  f1_time, f1_hr = pts_fun(initial_time, cardio1)
  f2_time, f2_hr = pts_fun(initial_time, cardio2)
  lines = plt.plot(f1_time, f1_hr, 'r', f2_time, f2_hr, 'b')
  plt.ylabel("Heart Rate [bpm]")
  plt.xlabel("Seconds from begining")
  plt.title("Heart Rate Monitor Comparison")
  plt.grid(True)
  plt.figlegend((lines), (descriptor1, descriptor2), 'lower right')

  plt.show()
开发者ID:javiere,项目名称:GPXCardio,代码行数:28,代码来源:GPXCardio.py

示例5: percplot

def percplot(data, perclist, file_name='weight_update_percentile', file_extension='.png', save_im=True, disp_im=False,
             sety=True):
    """Plot percentiles of weight update information during 'training1' of RBM object (RBM_m.py)

    :param data: list of lists, each sublist containing the same percentiles of the weight update matrices
    :param perclist: list of used percentiles
    :param file_name: name of optional output file (default: 'weight_update_percentile')
    :param file_extension: extension of optional output file (default: '.png')
    :param save_im: whether to save image (default: True)
    :param disp_im: whether to show image (default: False)
    :param sety: whether to set the y-range to predefined limits (default: True)
    :return: nothing, displays plot or saves plot to output file
    """

    fig = plt.figure()
    lines = plt.plot(data)
    plt.ylabel('update / weight')
    plt.xlabel('batch number')

    if sety:
        plt.ylim([-0.1, 0.1])

    plt.figlegend(lines, perclist, 'upper right')

    if disp_im:
        plt.show()

    if save_im:
        # Save to (.png) file, remove white border
        plt.savefig("{}{}".format(file_name, file_extension), bbox_inches='tight')

    plt.close(fig)                  # Clear current figure
开发者ID:Willemijn42,项目名称:RBM-numerosity,代码行数:32,代码来源:loose_fun_an.py

示例6: med_spread_plot

def med_spread_plot(data, obj_names, fig_name="temp.png", **settings):
  fig = plt.figure(1)
  fig.subplots_adjust(hspace=0.5)
  directory = fig_name.rsplit("/", 1)[0]
  mkdir(directory)
  for i, data_map in enumerate(data):
    meds = data_map["meds"]
    iqrs = data_map.get("iqrs", None)
    if iqrs:
      x = range(len(meds))
      index = int(str(len(data))+"1"+str(i+1))
      plt.subplot(index)
      plt.title(obj_names[i])
      plt.plot(x, meds, 'b-', x, iqrs, 'r-')
      plt.ylim((min(iqrs)-1, max(meds)+1))
    else:
      x = range(len(meds))
      index = int(str(len(data))+"1"+str(i+1))
      plt.subplot(index)
      plt.title(obj_names[i])
      plt.plot(x, meds, 'b-')
      plt.ylim((min(meds)-1, max(meds)+1))
  blue_line = mlines.Line2D([],[], color='blue', label='Median')
  red_line = mlines.Line2D([],[], color='red', label='IQR')
  plt.figlegend((blue_line, red_line), ('Median', 'IQR'), loc=9, bbox_to_anchor=(0.5, 0.075), ncol=2)
  plt.savefig(fig_name)
  plt.clf()
开发者ID:ai-se,项目名称:softgoals,代码行数:27,代码来源:plotter.py

示例7: rcp

def rcp(results, graphNames):
  rsltSize = results[0].size / 3 
  prec = range(0,rsltSize)
  precN = range(0,rsltSize)
  recall = range(0, rsltSize)

  for r in results:
    for x in range(0,rsltSize):
      numPos = float(r[0,x][0])
      if numPos == 0:
        prec[x] = 1
      else:
        prec[x] = r[0,x][2] / numPos

    for x in range(0,rsltSize):
      recall[x] = r[0,x][2] / float(r[0,x][1])

    for x in range(0,rsltSize):
      precN[x] = 1- prec[x]

    graph = plt.plot(precN,recall)
    graphs.append(graph)

  # plot settings
  plt.ylabel('Recall')
  plt.xlabel('1 - Precision')
  plt.axis([0, 1.0, 0, 1.0])
  plt.grid(True)

  # legend for our graphs
  plt.figlegend( (graphs), graphNames,'upper left')
开发者ID:crocdialer,项目名称:libccf,代码行数:31,代码来源:plotRCP.py

示例8: __init__

    def __init__(self, window, subplot_num, x_axis, dim=2):
        ax = window.add_subplot(subplot_num)
        l = len(x_axis)
        self.y = ax.plot(range(l), l*[-1,], '-',       # Obtain handle to y axis.
                         range(l), l*[-1,], '--',
                         marker='^'
                         )
        # Hack: because initially the graph has too few y points, compared to x points,
        # nothing should be shown on the graph.
        # The hack is that initial y axis is seto be be below in hell.
        self.y_data = []
        for i in range(dim):
            self.y_data.append( col.deque(len(x_axis)*[-9999,],          # Circular buffer.
                                          maxlen=len(x_axis)
                                          )
                              )

        # Make plot prettier
        plt.grid(True)
        plt.tight_layout()
        ax.set_ylim(MIN_TEMP, MAX_TEMP)
        plt.figlegend(self.y, ('tempr', 'ctrl'), 'upper right');
        ax.set_ylabel('temperature [C]')
        # Terrible hack!
        if subplot_num == 121:
            ax.set_xlabel('time [s]')
        else:
            ax.set_xlabel('time [min]')
开发者ID:MiroslavVitkov,项目名称:rtplot,代码行数:28,代码来源:plot.py

示例9: plotDif

def plotDif(leap, est, tMag, setName):
    styleL = ["solid", "dashed", "dotted", "dashdot"]
    if len(est[0]) == 3:
        leap = leap[:, :-1]

    plt.figure()

    statesP = plt.subplot(211)

    #    for i in range(0,len(est[0]),1):
    for i in range(0, 1, 4):
        statesP.plot(tMag, leap[:, i], c="r", ls=styleL[i])
        statesP.plot(tMag, est[:, i], c="g", ls=styleL[i])

    #    statesP.legend()
    statesP.set_ylabel("Angle [rad]")
    statesP.set_title("Difference " + setName)

    difP = plt.subplot(212)
    dif = leap - est[:, :4]
    normedDif = np.linalg.norm(dif, axis=1)

    difP.plot(tMag, normedDif, c="g", ls="-")

    difP.set_ylabel("Normed Difference [rad]")
    difP.set_xlabel("Time [sec]")

    linePerf = mlines.Line2D([], [], color="r", markersize=15, label="Leap")
    lineEst = mlines.Line2D([], [], color="g", markersize=15, label="Estimated")
    plt.figlegend((linePerf, lineEst), ("Leap", "Estimated"), loc="upper right")
开发者ID:MuellerDaniel,项目名称:SensGlove,代码行数:30,代码来源:160226_leapVsEst.py

示例10: PlotGraphs

def PlotGraphs(posDistList, negDiNucDist, graphFileName):
	global threeUtrValues, threeUtrErrors;

	import matplotlib
	matplotlib.use('Agg')
	
	from matplotlib import pyplot as plt	
	matplotlib.rcParams.update({'font.size': 8})

	posMeanValues = [x[0] for x in posDistList.values()]
	posErrorValues = [x[1] for x in posDistList.values()]	

	negMeanValues = [x[0] for x in negDiNucDist.values()]
	negErrorValues = [x[1] for x in negDiNucDist.values()]	

	#Two subplots, the axes array is 1-d
	fig, (ax1, ax2) = plt.subplots(nrows=2)
	fig.suptitle("Di-nucleotide distribution: 3'UTR vs Generated Files", fontsize=8)
	labels = posDistList.keys();
	eb1, eb2 = distribution_plot(ax1, "Positive Set", posMeanValues, posErrorValues, labels);
	eb1, eb2 = distribution_plot(ax2, "Negative Set", negMeanValues, negErrorValues, labels);

	plt.figlegend((eb1, eb2), ("Generated", "3'UTR"), loc = 'lower right');
	plt.savefig(graphFileName);
	plt.close(fig)
开发者ID:shwetabhandare,项目名称:PySG,代码行数:25,代码来源:generateGraphs.py

示例11: VisualizeReferenceSpectrum

def VisualizeReferenceSpectrum(rf_files, freq_sampling):
    plt.figure(1, figsize=(5, 4))
    handles = []
    labels = []
    for rf_file in rf_files:
        ComponentType = itk.ctype('float')
        Dimension = 2
        ImageType = itk.VectorImage[ComponentType, Dimension]
        reader = itk.ImageFileReader[ImageType].New(FileName=rf_file)
        reader.Update()
        image = reader.GetOutput()
        arr = itk.GetArrayFromImage(image)
        arr /= arr[:,:,arr.shape[2]/3-arr.shape[2]/5:arr.shape[2]/2+arr.shape[2]/5].max()
        freq = np.linspace(freq_sampling / 2 / arr.shape[2], freq_sampling / 2, arr.shape[2])
        ax = plt.plot(freq, arr[0, 0, :].ravel(), label=rf_file)
        handles.append(ax[0])
        labels.append(rf_file)
        plt.xlabel('Frequency [Hz]')
        plt.ylabel('Power spectrum [V]')
    plt.figlegend(handles, labels, 'upper right')
    plt.ylim(0.0, 1.0)

    dirname = os.path.dirname(rf_files[0])
    plt.savefig(os.path.join(dirname, 'ReferenceSpectrum.png'), dpi=300)
    plt.show()
开发者ID:KitwareMedical,项目名称:FAST,代码行数:25,代码来源:Visualize_Reference_Spectrum.py

示例12: model_effects_plot

def model_effects_plot():
    grs = linspace(0.01,1,15)
    simple = grs
    neg = linspace(-0.4,0.01,6)
    simple = simple/simple.mean()
    degraded = grs+0.4
    degmean = degraded.mean()
    degraded = degraded/degmean
    neg_deg = neg+0.4
    neg_deg = neg_deg/degmean
    rate = 1/(1+0.2/grs)
    rate_effect = grs/rate
    rate_effect = rate_effect/rate_effect.mean()
    figure(figsize=(5,3))
    ax = subplot(111)
    ax.plot(grs,simple,'o',label="Unregulated protein - basic model")
    ax.plot(grs,degraded,'o',label="Unregulated protein - with degradation")
    ax.plot(neg,neg_deg,'--g')
    ax.plot(grs,rate_effect,'o',label="Unregulated protein - under decreasing biosynthesis rate")
    ax.plot(grs,rate,'--r',label="Biosynthesis rate")
    ax.annotate("degradation\nrate", xy=(-0.4,0),xytext=(-0.4,.6),arrowprops=dict(facecolor='black',shrink=0.05,width=1,headwidth=4),horizontalalignment='center',verticalalignment='center',fontsize=8)
    ax.set_xlim(xmin=-0.5)
    ax.set_ylim(ymin=0.)
    ax.set_xlabel('Growth rate [$h^{-1}$]',fontsize=8)
    set_ticks(ax,6)
    ax.spines['left'].set_position('zero')
    ax.spines['right'].set_color('none')
    ax.spines['top'].set_color('none')
    ax.set_ylabel('Normalized protein concentration',fontsize=8)
    tight_layout()
    subplots_adjust(top=0.83)
    handles,labels=ax.get_legend_handles_labels()
    figlegend(handles,labels,fontsize=6,mode='expand',loc='upper left',bbox_to_anchor=(0.0,0.8,1,0.2),ncol=2,numpoints=1)
    savefig('TheoreticalModelEffects.pdf')
    close()
开发者ID:uriba,项目名称:proteome-analysis,代码行数:35,代码来源:proteome-analysis.py

示例13: plot_all_dbs_hist

def plot_all_dbs_hist():
    figure(figsize=(6.5,5))
    dbs = ['Heinemann-chemo','Peebo-gluc','Valgepea','HuiAlim','HuiClim','HuiRlim']
    dbext = {'Heinemann-chemo':'','Peebo-gluc':'','Valgepea':'','HuiAlim':', A-lim','HuiClim':', C-lim','HuiRlim':', R-lim'}
    p=subplot(111)
    for i,db in enumerate(dbs):
        ps = subplot(231+i)
        conds,gr,conc_data = datas[""][db]
        plot_corr_hist(ps,db,conc_data,categories)
        if db == 'Valgepea':
            year = 2013
        else:
            year = 2015
        ps.annotate("data from %s et. al. %d%s" % (db_name[db],year,dbext[db]),xy=(0.5,0.5),xytext=(-0.87,303),fontsize=6,zorder=10)
        ps.set_ylim(0,350)
        ps.set_xlim(-1,1)
        ps.annotate(chr(65+i),xy=(0.5,0.5),xytext=(-0.87,320),fontsize=10,zorder=10)

    #assume both subplots have the same categories.
    handles,labels=ps.get_legend_handles_labels()

    tight_layout()
    figlegend(handles,labels,fontsize=6,mode='expand',loc='upper left',bbox_to_anchor=(0.15,0.8,0.7,0.2),ncol=2)

    subplots_adjust(top=0.9)
    #fig = gcf()
    #py.plot_mpl(fig,filename="Growth rate Correlation histograms")
    savefig('AllDbsGrowthRateCorrelation.pdf')
    close()
开发者ID:uriba,项目名称:proteome-analysis,代码行数:29,代码来源:proteome-analysis.py

示例14: regional_sa

def regional_sa(model, expr, policy={}, nsamples=1000):
    samples = sample_lhs(model, nsamples)
    output = evaluate(model, overwrite(samples, policy))
    classification = output.apply(expr)
    classes = sorted(set(classification))
    fig, axarr = plt.subplots(1, len(model.uncertainties))
    lines = []
    
    for i, u in enumerate(model.uncertainties):
        for k in classes:
            indices = [classification[j] == k for j in range(len(classification))]
            values = [output[j][u.name] for j in range(len(indices)) if indices[j]]
            sorted_values = sorted(enumerate(values), key=operator.itemgetter(1))
            h = axarr[i].plot([v[1] for v in sorted_values], np.arange(len(values))/float(len(values)-1))
            lines.append(h[0])
            
        values = [output[j][u.name] for j in range(len(indices))]
        sorted_values = sorted(enumerate(values), key=operator.itemgetter(1))
        h = axarr[i].plot([v[1] for v in sorted_values], np.arange(len(values))/float(len(values)-1))
        lines.append(h[0])
        
        axarr[i].set_title(u.name)
        
    plt.figlegend(lines[:len(classes)] + [lines[-1]],
                  map(str, classes) + ["Unconditioned"],
                  loc='lower center',
                  ncol=3,
                  labelspacing=0. )
    
    return fig
开发者ID:arita37,项目名称:Rhodium,代码行数:30,代码来源:sa.py

示例15: rank_plot

 def rank_plot(self, rank_thresh = 100, show = True, filename = None):
     """Returns plot of the frequencies of the attributes, sorted by rank."""
     plt.figure()
     afdf = self.attr_freq_df(rank_thresh)
     cmap = plt.cm.gist_ncar
     colors = {i : cmap(int((i + 1) * cmap.N / (self.num_attr_types + 1.0))) for i in range(self.num_attr_types)}
     fig, (ax1, ax2) = plt.subplots(2, 1, sharex = False, sharey = False, facecolor = 'white')
     plots_for_legend = []
     for (i, t) in enumerate(self.attr_types):
         afdf_for_type = afdf[afdf['type'] == t]
         plots_for_legend.append(ax1.plot(afdf_for_type['rank'], np.log10(afdf_for_type['freq']), color = colors[i], linewidth = 2)[0])
         ax2.plot(afdf_for_type['rank'], afdf_for_type['cumulative %'], color = colors[i], linewidth = 2)
     ax1.set_title('Attribute frequencies by type', fontweight = 'bold')
     ax2.set_xlabel('rank')
     ax1.set_ylabel('log10(freq)')
     ax2.set_ylabel('cumulative %')
     ax2.set_ylim((0, 100))
     ax1.grid(True, 'major', color = 'w', linestyle = '-')
     ax2.grid(True, 'major', color = 'w', linestyle = '-')
     ax1.set_axisbelow(True)
     ax2.set_axisbelow(True)
     ax1.patch.set_facecolor('0.89')
     ax2.patch.set_facecolor('0.89')
     plt.figlegend(plots_for_legend, self.attr_types, 'right', fontsize = 10)
     if filename:
         plt.savefig(filename)
     if show:
         plt.show(block = False)
开发者ID:jeremander,项目名称:AttrVN,代码行数:28,代码来源:attr_vn.py


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