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


Python pyplot.annotate函数代码示例

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


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


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