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

Python pyplot.annotate函数代码示例

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

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



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

示例1: plot_error

def plot_error(station):
    fig_length = 10
    fig_width = 1
    background_color = '#e0e0e0'
    output_file = '%s.png' % station
        
    fig = plt.figure(facecolor=background_color, figsize =(fig_length, fig_width), dpi=100)
        
    ax = plt.subplot(1, 1, 1)
        
    plt.annotate('Waveforms currently unavailable', (0, 0), (250, 15), xycoords='axes fraction', textcoords='offset points', va='top')
        
    for ylabel in ax.get_yticklabels():
        ylabel.set_visible(False)
        
    for xlabel in ax.get_xticklabels():
        xlabel.set_visible(False)
        
    ax.yaxis.set_major_locator(plt.NullLocator())
    ax.yaxis.grid(False)
        
    plt.tight_layout()    
    #plt.show()
        
    plt.savefig(output_file, dpi=100, facecolor=fig.get_facecolor(), edgecolor='none', bbox_inches='tight')
    plt.close()  
开发者ID:mgardine,项目名称:aec_code,代码行数:26,代码来源:waveform_plot.py


示例2: execute_solver

def execute_solver(IMAGE_FILE):
    sample4x4_crop = import_image(IMAGE_FILE)
    cluster_image = get_clustering_image(sample4x4_crop)
    cluster_groupings_dict = cluster_grouper(cluster_image).execute()
    final = pre_process_image(IMAGE_FILE)
    prediction_dict = clean_prediction_dict(get_predictions(final))
    write_puzzle_file(cluster_groupings_dict,prediction_dict)
    try:
        solution = solve_puzzle('cv_puzzle.txt',False)
    except:
        return 'error'

    #get image of result
    fig = plt.figure(figsize=(2, 2), dpi=100,frameon=False)
    plt.axis('off')
    plt.imshow(sample4x4_crop, cmap=mpl.cm.Greys_r)
    for k,v in solution.items():
        if v == None:
            return 'error'
        plt.annotate('{}'.format(v), xy=(k[0]*50+12,k[1]*50+40), fontsize=14)
    plt.tight_layout()
    plt.savefig('static/images/solution.jpg', bbox_inches='tight', dpi=100)

    #theres an issue with the saved layout, tight_layout
    #doesn't appear to work so I need to apply my own cropping again
    resize_final = import_image('static/images/solution.jpg',80)
    imsave('static/images/solution.jpg',resize_final)
    return 'good'
开发者ID:kennmyers,项目名称:Metis-Projects,代码行数:28,代码来源:kenkensolver.py


示例3: plot

def plot(i, pcanc, lr, pp, labelFlag, Y):
    if len(str(i)) == 1:
        fig = plt.figure(i)
    else:
        fig = plt.subplot(i)
    if pcanc == 0:
        plt.title(
                  ' learning_rate: ' + str(lr)
                + ' perplexity: ' + str(pp))
        print("Plotting tSNE")
    else:
        plt.title(
                  'PCA-n_components: ' + str(pcanc)
                + ' learning_rate: ' + str(lr)
                + ' perplexity: ' + str(pp))
        print("Plotting PCA-tSNE")
    plt.scatter(Y[:, 0], Y[:, 1], c=colors)
    if labelFlag == 1:
        for label, cx, cy in zip(y, Y[:, 0], Y[:, 1]):
            plt.annotate(
                label.decode('utf-8'),
                xy = (cx, cy),
                xytext = (-10, 10),
                fontproperties=font,
                textcoords = 'offset points', ha = 'right', va = 'bottom',
                bbox = dict(boxstyle = 'round,pad=0.5', fc = 'yellow', alpha = 0.9))
                #arrowprops = dict(arrowstyle = '->', connectionstyle = 'arc3,rad=0'))
    ax.xaxis.set_major_formatter(NullFormatter())
    ax.yaxis.set_major_formatter(NullFormatter())
    plt.axis('tight')
    print("Done.")
开发者ID:CORDEA,项目名称:niconico-visualization,代码行数:31,代码来源:mds_plot_hamming.py


示例4: main

def main():
    svd = TruncatedSVD()
    Z = svd.fit_transform(X)
    plt.scatter(Z[:,0], Z[:,1])
    for i in xrange(D):
        plt.annotate(s=index_word_map[i], xy=(Z[i,0], Z[i,1]))
    plt.show()
开发者ID:ShuvenduBikash,项目名称:machine_learning_examples,代码行数:7,代码来源:lsa.py


示例5: debugFormicMetaGraph

def debugFormicMetaGraph (fmg, mazeLong):
    """
    Format a output for pyplot that renders the formic meta graph
    """

    # import
    try:
        import matplotlib.pyplot as plt
    except:
        debug ("Matplotlib not found")
        return
    
    # plot
    for i in fmg:
        for j in fmg[i]:
            dotY = [-i[0], -j[0]]
            dotX = [i[1], j[1]]
            plt.plot(dotX, dotY, "o:")

            if (i[0]-mazeLong)**2+i[1]**2 > (j[0]-mazeLong)**2+j[1]**2:
                plt.annotate (str(j)+'<-'+str(i)+' '+str(fmg[i][j][0])+' '+str(fmg[i][j][1]), ( (i[1]+j[1])/2.0 - 0.4, -((i[0]+j[0])/2.0 -0.1) ))
            else:
                plt.annotate (str(i)+'->'+str(j)+' '+str(fmg[i][j][0])+' '+str(fmg[i][j][1]), ( (i[1]+j[1])/2.0 - 0.4, -((i[0]+j[0])/2.0 +0.1) ))
    
    # render
    plt.axis((-0.5,mazeLong-0.5, -mazeLong+0.5, 0.5))
    plt.show()
开发者ID:TeamRoquette,项目名称:PyRat,代码行数:27,代码来源:TeamRoquetteSuperInfectedMushroom.py


示例6: plot_results

def plot_results(algo, datas, xlabel, ylabel, note, factor=None):
    plt.clf()
    fig1, ax1 = plt.subplots()
    plt.figtext(0.90, 0.94, "Note: " + note, va='top', ha='right')
    w, h = fig1.get_size_inches()
    fig1.set_size_inches(w*1.5, h)
    ax1.set_xscale('log')
    ax1.get_xaxis().set_major_formatter(ticker.ScalarFormatter())
    ax1.get_xaxis().set_minor_locator(ticker.NullLocator())
    ax1.set_xticks(datas[0][:,0])
    ax1.grid(color="lightgrey", linestyle="--", linewidth=1, alpha=0.5)
    if factor:
        ax1.set_xticklabels([str(int(x)) for x in datas[0][:,0]/factor])
    plt.xlabel(xlabel, fontsize=16)
    plt.ylabel(ylabel, fontsize=16)
    plt.xlim(datas[0][0,0]*.9, datas[0][-1,0]*1.1)
    plt.suptitle("%s Performance" % (algo), fontsize=28)

    for backend, data in zip(backends, datas):
        N = data[:, 0]
        plt.plot(N, data[:, 1], 'o-', linewidth=2, markersize=5, label=backend)
        dy = max(data[:,1]) / 20.0
        for x, y in zip(N, data[:, 1]):
            plt.annotate('%.1f' % y, (x, y+dy))
        plt.legend(loc='upper left', fontsize=18)

    plt.savefig(algo + '.png')
开发者ID:chtlp,项目名称:mkl-optimizations-benchmarks,代码行数:27,代码来源:plot_results.py


示例7: plot_confusion_matrix

 def plot_confusion_matrix(self, y_test, y_pred, list_classes):
     cm = self.confusion_matrix(y_test, y_pred)
     plt.figure()
     plt.imshow(cm, interpolation='nearest', cmap=plt.cm.Blues)
     plt.title('Confusion matrix')
     plt.colorbar()
     tick_marks = np.arange(len(list_classes))
     plt.xticks(tick_marks, list_classes, rotation=90)
     plt.yticks(tick_marks, list_classes)
     plt.tight_layout()
     plt.ylabel('True label')
     plt.xlabel('Predicted label')
     plt.grid(True)
     width, height = len(list_classes), len(list_classes)
     for x in range(width):
         for y in range(height):
             if cm[x][y] > 100:
                 color = 'white'
             else:
                 color = 'black'
             if cm[x][y] > 0:
                 plt.annotate(str(cm[x][y]), xy=(y, x),
                              horizontalalignment='center',
                              verticalalignment='center',
                              color=color)
     plt.show()
开发者ID:rafaelpossas,项目名称:usyd-kd-textclassification,代码行数:26,代码来源:Base.py


示例8: plot_confusion_matrix

    def plot_confusion_matrix(self, y_true, y_pred, list_classes, title='Confusion matrix', filename='confusion_matrix.png'):

        # compute confusion matrix
        cm = confusion_matrix(y_true,y_pred)

        conf_mat_norm = cm.astype('float') / cm.sum(axis=1)[:, np.newaxis]

        conf_mat2 = np.around(conf_mat_norm,decimals=2) # rounding to display in figure

        fig = plt.figure(figsize=(16,16), dpi=100)
        plt.imshow(conf_mat2,interpolation='nearest')

        for x in xrange(len(list_classes)):
          for y in xrange(len(list_classes)):
            plt.annotate(str(conf_mat2[x][y]),xy=(y,x),ha='center',va='center')

        plt.xticks(range(len(list_classes)),list_classes,rotation=90,fontsize=11)
        plt.yticks(range(len(list_classes)),list_classes,fontsize=11)

        plt.tight_layout(pad=3.)

        plt.title(title)
        plt.colorbar()

        # plt.show()
        fig.savefig(filename)
开发者ID:allansp84,项目名称:license-plate,代码行数:26,代码来源:classification.py


示例9: make_xi_plot

def make_xi_plot():
	from numpy import linspace
	from matplotlib import pyplot as pl
	pl.rc('text', usetex=True)
	pl.rc('font', family='serif')
	lamdas = [-1,-0.9,-0.7,0,0.7,0.9,1]
	for lam in lamdas:
		plotx(lam,0,linestyle='k',minval=-0.9,maxval=10.0,logplot=True)
		plotx(lam,1,linestyle='k--',logplot=True)
		plotx(lam,2,logplot=True)
		plotx(lam,3,linestyle='k--',logplot=True)
	pl.vlines(x=1,ymin=-2,ymax=-0.076,color='k')
	pl.xlabel(r'$$\xi$$',fontsize=16)
	pl.ylabel(r'$$\tau$$',fontsize=16)
	pl.text(0.0, 0, r'$$M=0$$', bbox=dict(facecolor='white', alpha=1))
	pl.text(0.0, 1.4, r'$$M=1$$', bbox=dict(facecolor='white', alpha=1))
	pl.text(0, 2.48, r'$$M=2$$', bbox=dict(facecolor='white', alpha=1))
	pl.text(1.3, -1.5, r'hyperbolic')
	pl.text(0.3, -1.5, r'elliptic')
	pl.annotate(r'$$\lambda = 1$$', xy=(-0.29, -0.19), xytext=(-1, -1),
            arrowprops=dict(facecolor='black', shrink=0.15, width=1,headwidth=5),
            )
	pl.annotate(r'$$\lambda = -1$$', xy=(0.7, 0.4), xytext=(0.8,0.8),
            arrowprops=dict(facecolor='black', shrink=0.15, width=1,headwidth=5),
            )
	pl.xlim((-2,2))
	pl.ylim((-2,3))
开发者ID:darioizzo,项目名称:lambert,代码行数:27,代码来源:lambert.py


示例10: make_starter_plot

def make_starter_plot():
	from numpy import linspace
	from math import pi
	from matplotlib import pyplot as pl
	pl.rc('text', usetex=True)
	pl.rc('font', family='serif')
	pl.axvline(x=1,color='k')
	pl.xlabel(r'$$x$$',fontsize=16)
	pl.ylabel(r'$$T$$',fontsize=16)
	pl.text(0.5, 4, r'hyperbolic')
	pl.text(1.2, 4, r'elliptic')
	plot_x_curves([-1,-0.85,0.85,1],N=0,logplot=False,maxval=10,minval=-0.9)
	T0s = [pi,pi/2,1.1]
	for T0 in T0s:
		T  =linspace(T0,10*pi)
		pl.plot((T0/T)**(2.0/3.0)-1.0,T,':k')
		T  =linspace(0.1,T0)
		pl.plot((T0/T)**(1.0)-1.0,T,':k')
	pl.plot([],'k-',label="tof curves [-1,-0.85,0.85,1]")
	pl.plot([],'k:',label="initial guesses")
	pl.legend()
	pl.annotate(r'$$\lambda \le -0.85$$', xy=(-0.4, 7.5), xytext=(-0.1, 8),
            arrowprops=dict(facecolor='black', shrink=0.15, width=1,headwidth=5),
            )
	pl.annotate(r'$$\lambda \ge 0.85$$', xy=(-0.33, 2.1), xytext=(-0.9, 1.09),
            arrowprops=dict(facecolor='black', shrink=0.15, width=1,headwidth=5),
            )
开发者ID:darioizzo,项目名称:lambert,代码行数:27,代码来源:lambert.py


示例11: make_x_plot

def make_x_plot():
	from numpy import linspace
	from matplotlib import pyplot as pl
	pl.rc('text', usetex=True)
	pl.rc('font', family='serif')
	lamdas = [-1,-0.9,-0.7,0,0.7,0.9,1]
	for lam in lamdas:
		plotx(lam,0)
		plotx(lam,1,linestyle='k--')
		plotx(lam,2)
		plotx(lam,3,linestyle='k--')
	pl.axvline(x=1,color='k')
	pl.xlabel(r'$$x$$',fontsize=16)
	pl.ylabel(r'$$T$$',fontsize=16)
	pl.text(0.0, 1.5, r'$$M=0$$', bbox=dict(facecolor='white', alpha=1))
	pl.text(0.0, 4.7, r'$$M=1$$', bbox=dict(facecolor='white', alpha=1))
	pl.text(0.0, 8.0, r'$$M=2$$', bbox=dict(facecolor='white', alpha=1))
	pl.text(0.5, 4, r'hyperbolic')
	pl.text(1.2, 4, r'elliptic')
	pl.annotate(r'$$\lambda = 1$$', xy=(-0.25, 1.1), xytext=(-0.8, 0.2),
            arrowprops=dict(facecolor='black', shrink=0.15, width=1,headwidth=5),
            )
	pl.annotate(r'$$\lambda = -1$$', xy=(0.5, 2.0), xytext=(0.7, 3.0),
            arrowprops=dict(facecolor='black', shrink=0.15, width=1,headwidth=5),
            )
开发者ID:darioizzo,项目名称:lambert,代码行数:25,代码来源:lambert.py


示例12: analyzeSound

    def analyzeSound(self):
        """ highlights N first peaks in frequency diagram
        """
        # on recharge les données 
        data = self.data
        sample_freq = self.sample_freq
        from scipy.fftpack import fftfreq
        freq_vect = fftfreq(data.size) * sample_freq
        
        # on trouve les maxima
        y0 = abs(fft(data))
#        y1 = abs(fft(data[:, 1]))
        maxi0 = ((diff(sign(diff(y0))) < 0) & (y0[1:-1] > y0.max()/10.)).nonzero()[0] + 1 # local max
        # maxi1 = ((diff(sign(diff(y1))) < 0) & (y1[1:-1] > y1.max()/10.)).nonzero()[0] + 1 # local max
        
        # fréquence
        ax = self.main_figure.figure.add_subplot(212)
        ax.plot(freq_vect[maxi0], y0[maxi0], "o")
        # ax.plot(freq_vect[maxi1], y1[maxi1], "o")
        
        # annotations au dessus d'une fréquence de coupure
        fc = 100
        for point in maxi0[(freq_vect[maxi0] > fc).nonzero()][:self.ui.spinBox.value()]:
            plt.annotate("%.2f" % freq_vect[point], (freq_vect[point], y0[point]))
#        for point in maxi1[(freq_vect[maxi0] > fc).nonzero()][:self.ui.spinBox.value()]:
#            plt.annotate("%.2f" % freq_vect[point], (freq_vect[point], y1[point]))
        
        self.ui.main_figure.canvas.draw()
开发者ID:GuitarTuner,项目名称:FloydRoseTremoloTuning,代码行数:28,代码来源:PyAudioApp.py


示例13: euclSpaceMapp

def euclSpaceMapp(gDirected,distMat,top100List,top100ListIdxs):
    print('extract euclidean space mapping')
    allCoordinates = euclideanCoords(gDirected,distMat)
    print('Mapped nodes to euclidean space')
    xpl=[x[0] for x in allCoordinates]
    minXpl = min(xpl)
    if minXpl < 0:
       aminXpl = abs(minXpl)
       xpl = np.array([x+aminXpl+1 for x in xpl])
    ypl=[x[1] for x in allCoordinates]
    minYpl = min(ypl)
    if minYpl < 0:
       aminYpl = abs(minYpl)
       ypl = np.array([y+aminYpl+1 for y in ypl])
    fig = pyplot.figure()
    ax = pyplot.gca()
    ax.scatter(xpl,ypl)
    ax.set_ylim(min(ypl)-1,max(ypl)+1)
    ax.set_xlim(min(xpl)-1,max(xpl)+1)
    labels = top100List
    for label, x, y in zip(labels, xpl[top100ListIdxs], ypl[top100ListIdxs]):
       pyplot.annotate(label, xy = (x, y), xytext = (-10, 10),textcoords = 'offset points', ha = 'right', va = 'bottom',
           bbox = dict(boxstyle = 'round,pad=0.2', fc = 'yellow', alpha = 0.5),
           arrowprops = dict(arrowstyle = '->', connectionstyle = 'arc3,rad=0'))
    interactive(True)
    pyplot.show()
    # pyplot.savefig('./images/'+str(year)+'_euclSpaceMapping_via_shortestPaths.jpg', bbox_inches='tight', format='jpg')
    pyplot.savefig('./images/'+str(year)+'_euclSpaceMapping_via_distMatrix.jpg', bbox_inches='tight', format='jpg')
    pyplot.close()
开发者ID:dinos66,项目名称:termAnalysis,代码行数:29,代码来源:termAnalysisPruned100.py


示例14: plot_Features

def plot_Features(sort_p_lower,sort_p_upper,X,y,vectorizer,n=5):
    for i in range(n):
       feature_Ind = sort_p_lower[i][2]
       ind_pos = np.nonzero(y)
       ind_neg = np.nonzero(y==0)
       sum_pos = np.sum(X[ind_pos,feature_Ind].toarray())
       sum_neg = np.sum(X[ind_neg,feature_Ind].toarray())
       a = plt.scatter(sum_pos,sum_neg,c='blue')
       plt.annotate(vectorizer.get_feature_names()[feature_Ind],(sum_pos,sum_neg))
    plt.xlabel("number of times in positive instances")
    plt.ylabel("number of times in negative instances")
    plt.title("top features for news coverage prediction")

    for i in range(n):
       feature_Ind = sort_p_upper[i][2]
       ind_pos = np.nonzero(y)
       ind_neg = np.nonzero(y==0)
       sum_pos = np.sum(X[ind_pos,feature_Ind].toarray())
       sum_neg = np.sum(X[ind_neg,feature_Ind].toarray())
       b = plt.scatter(sum_pos,sum_neg,c='red')
       plt.annotate(vectorizer.get_feature_names()[feature_Ind],(sum_pos,sum_neg))
    xmin,xmax = plt.xlim()
    ymin,ymax = plt.ylim()
    min_value = min([xmax,ymax])
    plt.xlim(0, xmax)
    plt.ylim(0, ymax)
    plt.plot(range(int(min_value)),range(int(min_value)),0.01,'-')
    plt.legend((a,b),('positive feature','negative feature'),scatterpoints=1,loc=4)
    #plt.show()
    plt.savefig("BS_NConPR/top_features_NC")
开发者ID:yezhang1989,项目名称:A-Data-Driven-Approach-to-Characterizing-the-Perceived-Newsworthiness-of-Health-ScienceArticles,代码行数:30,代码来源:BS_NConPR.py


示例15: Main

def Main():
    args=ParseArg()
    data=np.loadtxt(args.input,delimiter='\t',dtype=float)
    min_x=int(args.xlim[0])
    max_x=int(args.xlim[1])
    start=int(data[0,0])
    peak=data[:,1].argmax()
    plt.ioff()
    plt.plot(np.array(range(min_x,max_x)),data[(min_x-start):(max_x-start),1],color='r',label="real_count")
    if args.distogram:
        plt.annotate('local max: '+str(peak+start)+"bp",xy=(peak+start,data[peak,1]),xytext=(peak+start+30,0.8*data[peak,1]),)
                #   arrowprops=dict(facecolor='black', shrink=0.05))

    # smoth the plot
    xnew=np.linspace(min_x,max_x,(max_x-min_x)/5)
    smooth=spline(np.array(range(min_x,max_x)),data[(min_x-start):(max_x-start),1],xnew)
    plt.plot(xnew,smooth,color='g',label='smooth(5bp)')
    max_y=max(data[(min_x-start):(max_x-start),1])
    min_y=min(data[(min_x-start):(max_x-start),1])
    plt.xlabel("Distance")
    plt.ylabel("Counts")
    plt.xlim(min_x,max_x)
    plt.ylim(min_y*0.9,max_y*1.1)
    plt.title(os.path.basename(args.input).split("_"+str(start))[0])
    plt.legend()
    plt.savefig(os.path.basename(args.input).split("_"+str(start))[0]+"_%d~%dbp."%(min_x,max_x)+args.output)
    print >>sys.stderr,"output figure file generated!!"
开发者ID:ShuklaAshutosh,项目名称:tools,代码行数:27,代码来源:plot_histogram.py


示例16: advance

 def advance(self, t, plotresult=False):
     y0 = self.concs * self.molWeight
     y0 = append(y0, self.thickness)
     yt = odeint(self.rightSideofODE, y0, t)
     if (plotresult):
         import matplotlib.pyplot as plt
         plt.figure()
         plt.axes([0.1, 0.1, 0.6, 0.85])
         plt.semilogy(t, yt)
         plt.ylabel('mass concentrations (kg/m3)')
         plt.xlabel('time(s)')
         #plt.legend(self.speciesnames)
         for i in range(len(self.speciesnames)):
             plt.annotate(
                 self.speciesnames[i], (t[-1], yt[-1, i]),
                 xytext=(20, -5),
                 textcoords='offset points',
                 arrowprops=dict(arrowstyle="-"))
         plt.show()
     self.thickness = yt[-1][-1]
     ytt = yt[-1][:-1]
     #        for iii in range(len(ytt)):
     #            if ytt[iii]<0:
     #                ytt[iii]=0.
     molDens = ytt / self.molWeight
     self.concs = molDens
     self.molFrac = molDens / sum(molDens)
     self.massFrac = ytt / sum(ytt)
开发者ID:weasky,项目名称:LiquidGasSimulation,代码行数:28,代码来源:evapor.py


示例17: plotCurves

def plotCurves(losses,rateOfExceedance,return_periods,lossLevels):

    plt.figure(1, figsize=(8, 6), dpi=80, facecolor='w', edgecolor='k')
    plt.scatter(losses,rateOfExceedance,s=20)
    if len(return_periods) > 0:
        annual_rate_exc = 1.0/np.array(return_periods)
        for rate in annual_rate_exc:
            if rate > min(rateOfExceedance):
                plt.plot([min(losses),max(losses)],[rate,rate],color='red') 
                plt.annotate('%.6f' % rate,xy=(max(losses),rate),fontsize = 12)

    plt.yscale('log')
    plt.xscale('log')
    plt.ylim([min(rateOfExceedance),1])
    plt.xlim([min(losses),max(losses)])
    plt.xlabel('Losses', fontsize = 16)
    plt.ylabel('Annual rate of exceedance', fontsize = 16)

    setReturnPeriods = 1/rateOfExceedance
    plt.figure(2, figsize=(8, 6), dpi=80, facecolor='w', edgecolor='k')
    plt.scatter(setReturnPeriods,losses,s=20)
    if len(return_periods) > 0:
        for period in return_periods:
            if period < max(setReturnPeriods):
                plt.plot([period,period],[min(losses),max(losses)],color='red') 
                plt.annotate(str(period),xy=(period,max(losses)),fontsize = 12)

    plt.xscale('log')
    plt.xlim([min(setReturnPeriods),max(setReturnPeriods)])
    plt.ylim([min(losses),max(losses)])
    plt.xlabel('Return period (years)', fontsize = 16)
    plt.ylabel('Losses', fontsize = 16)
开发者ID:lmcsousa,项目名称:rmtk,代码行数:32,代码来源:loss_modelling.py


示例18: plotAotiHour

def plotAotiHour():

    fig = plt.figure(figsize=(18, 5))
    rect = fig.patch
    rect.set_facecolor("white")
    df = pd.read_csv("urban-country/aoti_pm25.csv", sep=",", header=0)
    df = df[df["date"] >= 20140514]
    df = df[df["date"] <= 20140527]
    df["date"] = df["date"].astype(str)
    df["hour"] = df["hour"].astype(str)
    dateAndTime = pd.to_datetime(df["date"] + df["hour"], format="%Y%m%d%H")
    aoti = df["奥体中心"].tolist()
    ts_aoti = Series(aoti, index=dateAndTime)
    plot = ts_aoti.plot(linestyle="-", color="black", marker="8", markersize=4, label=u"奥体中心")
    time = dt.datetime(2014, 05, 17, 10)
    df = df[df["date"] == "20140517"]
    df = df[df["hour"] == "10"]
    value = df.iloc[0, 3]
    print mdates.date2num(time), value
    plt.annotate(
        u"aoti24",
        xy=(mdates.date2num(time), value),
        xytext=(30, 20),
        textcoords="offset points",
        arrowprops=dict(arrowstyle="-|>"),
    )
    plt.show()
开发者ID:wuliangradi,项目名称:PM25,代码行数:27,代码来源:beijingPM25.py


示例19: annotatePlot

    def annotatePlot(X, index, annotes, button):
        """Create popover label in 3d chart

        Args:
            X (np.array) - array of points, of shape (numPoints, 3)
            index (int) - index (into points array X) of item which should be printed
        Returns:
            None
        """
        # If we have previously displayed another label, remove it first
        if hasattr(annotatePlot, 'label'):
            annotatePlot.label.remove()

        if button == 2:
            # Get data point from array of points X, at position index
            x2, y2, _ = proj3d.proj_transform(X[index, 0], X[index, 1], X[index, 2], ax.get_proj())

            annote = annotes[index]

            annotatePlot.label = plt.annotate(annote,
                                              xy=(x2, y2), xytext=(-20, 20), textcoords='offset points', ha='right',
                                              va='bottom',
                                              bbox=dict(boxstyle='round,pad=0.5', fc='yellow', alpha=0.5),
                                              arrowprops=dict(arrowstyle='->', connectionstyle='arc3,rad=0'))
        # if we press another button (i.e. to pan the axis we need to create a dummy (blank) annotate
        # this is because the annotePlot still has an attribute (it has previously been called
        elif button != 2:
            annotatePlot.label = plt.annotate('', xy=(0, 0), xytext=(0, 0))

        fig.canvas.draw()
开发者ID:outdoorpet,项目名称:3D_click_annotate,代码行数:30,代码来源:_3D_mouseclick.py


示例20: plot_minos_fit

	def plot_minos_fit(self,p,decay="X",title="Fit Results",erange=9,step=4.07,lum=4200):
		fig = plt.figure(figsize=(8,6))
		plt.errorbar(self.x,self.y,self.yerr,fmt='o')
		M = p[0][0]
		G = p[1][0]
		B = p[2][0]
		dMl = p[0][1]
		dMu = p[0][2]
		dGl = p[1][1]
		dGu = p[1][2]
		dBl = p[2][1]
		dBu = p[2][2]
		x_fit = np.linspace(min(self.x),max(self.x),num=100)
		plt.plot(x_fit,self.convBWG(x_fit,M,G,B))
		plt.xlabel("$\sqrt{\hat{s}} (MeV)$",fontsize=16)
		plt.ticklabel_format(useOffset=False)
		plt.ylabel("Counts",fontsize=16)
		plt.title(title,fontsize=16)
		lbl1 = "Input:\n$\mathcal{L}=%d pb^{-1}$\n$\Delta=%.3f\ MeV$\n$\delta\sqrt{\hat{s}} = %.3f MeV$" % (lum,step,self.beam)
		lbl1 = lbl1 + "\n$M_h = 125.0 GeV$\n$\Gamma_h = 4.07 MeV$\n$Br(h^0\\rightarrow$%s$) = %.3f$" % (decay, self.higgs[2])
		lbl1 = lbl1 + "\n$\sigma_{bkg} = %.2f pb^{-1}$" % (self.bkg)
		lbl2 = "\nFit results:\n"
		lbl2 = lbl2 + "$\Delta M_h = %.3f_{-%.3f}^{+%.3f}\ MeV$\n" % (M-self.higgs[0], -1*dMl, dMu)
		lbl2 = lbl2 + "$\Gamma_h = %.3f_{-%.3f}^{+%.3f} \ MeV$\n" % (G, -1*dGl, dGu)
		lbl2 = lbl2 + "$Br(h^0\\rightarrow$%s$) = %.3f_{-%.3f}^{+%.3f}$\n" % (decay, B, -1*dBl, dBu)
		plt.annotate(lbl1, [0.1,0.6], xycoords='axes fraction',fontsize=15)
		plt.annotate(lbl2, [0.7,0.6], xycoords='axes fraction',fontsize=15)
		return plt
开发者ID:muCoConway,项目名称:higgs-measurements,代码行数:28,代码来源:subroutines.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python pyplot.arrow函数代码示例发布时间:2022-05-27
下一篇:
Python pylab.yticks函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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