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


Python pyplot.twiny函数代码示例

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


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

示例1: graphMembersOverTimeWithPlusMinusText

def graphMembersOverTimeWithPlusMinusText(membertimedata, memberinfos, membership):
    ydates, yvalues = zip(*membertimedata)
    ydates = list(ydates)
    #yvalues = map(lambda x:x[0],yvalues)
    plotlabel = [u"Number of members over time","Membership Income over time"]
    plt.plot(ydates, yvalues, 'o',linewidth=2, markevery=1)
    plt.ylabel("#Members")
    plt.xlabel("Month")
    plt.grid(True)
    plt.legend(plotlabel,loc='upper left')
    plt.twiny()
    plt.ylabel("Euro")
    #plt.title(plotlabel)
    ## label with +x-y members per month
    membersinmonth = dict(membertimedata)
    #print "\n".join([ "%s:%s" % (x[0],str(x[1])) for x in extractPlusMinusFromMemberships(membership).items()])
    pm_dates, pm_fee_dates = extractPlusMinusFromMemberships(membership)
    for astrdate, tpl in pm_dates.items():
        adate = datetime.datetime.strptime(astrdate, dateformat_monthonly_).date()
        assert(adate.day==1)
        if adate in membersinmonth:
            xy = (adate, membersinmonth[adate][0])
            xytext = (xy[0], xy[1]+1)
            plt.annotate(str(tpl), xy=xy, xytext=xytext,arrowprops=dict(facecolor='gray', shrink=0.5))
    for astrdate, tpl in pm_fee_dates.items():
        adate = datetime.datetime.strptime(astrdate, dateformat_monthonly_).date()
        assert(adate.day==1)
        if adate in membersinmonth:
            xy = (adate, membersinmonth[adate][1])
            xytext = (xy[0], xy[1]+30)
            plt.annotate(str(tpl), xy=xy, xytext=xytext,arrowprops=dict(facecolor='gray', shrink=0.5))
    plt.subplots_adjust(left=0.06, bottom=0.05, right=0.99, top=0.95)
开发者ID:btittelbach,项目名称:pyhledger,代码行数:32,代码来源:stats.py

示例2: plt_twin

def plt_twin( axis, tick0=None, tick=None ) : 
	'''
	Add x-top or y-right axis

	axis:
		['x' | 'y']

	tick0:
		Must between [0, 1]
	'''
	if (str(axis).lower() not in ['x', 'y']) : Raise(Warning, "axis='"+str(axis)+"' not in ['x', 'y']. Do nothing !")
	axis = str(axis).lower()
	#--------------------------------------------------
	if (tick0 is not None and tick is not None) : 
		tick0 = npfmt(tick0, float)
		if (tick0.min()<0 or tick0.max()>1) : 
			Raise(Warning, 'tick0.(min,max)=(%.1f, %.1f) out of [0, 1]. Do nothing !' % (tick0.min(), tick0.max()))
		else : 
			if   (axis == 'x') : 
				plt.twiny()
				plt.xticks(tick0, tick)
			elif (axis == 'y') : 
				plt.twinx()
				plt.yticks(tick0, tick)
	#--------------------------------------------------
	elif (tick0 is None and tick is None) : 
		if   (axis == 'x') : plt.tick_params(axis='x', which='both', labeltop='on', labelbottom='on')
		elif (axis == 'y') : plt.tick_params(axis='y', which='both', labelleft='on', labelright='on')
	#--------------------------------------------------
	else : Raise(Warning, 'tick0, tick must both ==None or !=None, now one is None but the other is not. Do nothing !')
开发者ID:jizhi,项目名称:huangqizhi_git,代码行数:30,代码来源:Plot.py

示例3: classificate

def classificate(X, bins=None, n_components=5, verbose=True,
        histogram_ylabel='X',
        histogram_xlabel='Frequency',
        gaussian_xlabel='Probability',
        scatter_xlabel='Point No.'):
    # create histogram data
    hist, bins = statistics_histogram.histogram(X, bins=bins)
    # create gaussian mixture model
    model, AIC, BIC = clustering_gaussian.fit(X, n_components)

    # plot histogram
    pl.subplot(121)
    plot_histogram.histogram(hist, bins, transposition=True, color='k', alpha=0.7)
    pl.xlabel(histogram_xlabel)
    pl.ylabel(histogram_ylabel)
    pl.grid()

    # plot gaussian
    pl.twiny()
    plot_gaussian.gaussian(X, model, transposition=True)
    pl.xlabel(gaussian_xlabel)
    pl.legend()

    # reverse y axis
    ymin, ymax = pl.ylim()
    pl.ylim(ymax, ymin)

    # plot classified scatter
    pl.subplot(122)
    plot_gaussian.gaussian_scatter(X, model)
    pl.ylim(ymax, ymin)
    pl.xlabel(scatter_xlabel)
    pl.ylabel(histogram_ylabel)
    pl.minorticks_on()
    pl.legend()
    pl.grid(which='major', alpha=0.5)
    pl.grid(which='minor', alpha=0.2)

    # print result in stdout if verbose
    if verbose:
        print histogram_xlabel
        print "N = %d, Bins = %d" % (len(X), len(bins))
        # individual fitting curve
        properties = zip(model.weights_, model.means_, model._get_covars())
        properties = sorted(properties, key=lambda x: x[1])
        for (weight, mean, covar) in properties:
            var = np.diag(covar)[0]
            # create formula of normal deviation
            formula_label = textutils.gaussian_formula(len(X), mean, var)
            formula_label = "%.1f%%: %s" % (weight * 100, formula_label)
            print formula_label.encode('utf-8')

    # show figure
    pl.show()
开发者ID:lambdalisue,项目名称:labst,代码行数:54,代码来源:misc.py

示例4: dualLIFPlot

 def dualLIFPlot(self, y = None):
     '''
         Makes a vertical LIF photon / s rate plot using internal lif
         averages.
     '''
     if y is None:
         y = self.dye_v - self.diode_v
     l1 = plt.plot(np.array([np.mean(x) for x in self.lif_avgs1]), y,
             color='red', label='PMT1')
     plt.xticks(color='red')
     plt.xlabel('ave photons / demod sample (photon kHz)', color='red')
     plt.title('PMT1 & 2 LIF Signal', y=1.08)
     plt.ylim(np.min(y), np.max(y))
     plt.twiny()
     l2 = plt.plot(np.array([np.mean(x) for x in self.lif_avgs2]), y,
             color='red', label='PMT2')
开发者ID:Smattacus,项目名称:data-analysis,代码行数:16,代码来源:vcorrs.py

示例5: plot_age

def plot_age(p, form, fof_np, age_labels, symbls):
    lims = 10. ** np.linspace(9, 15, (15.25-9) / .25) #These are the limits for the mass bins
    for (i, form_i) in enumerate(form):
        (avg, med) = binning(fof_np[i], form_i, lims)
        plt.semilogx(avg[0], avg[1], marker = symbls[i], subsx = [2, 3, 4, 5, 6, 7, 8, 9], \
                     label = 'Average {0}'.format(age_labels[i]))
        plt.semilogx(med[0], med[1], linestyle = 'dashed', label = 'Median {0}'.format(age_labels[i]))
    #MS = 13.5795 - 10.3112 * np.arcsinh(0.0504329 * avg[0] ** 0.08445)
    #plt.semilogx(avg[0], MS, 'r', label = 'MS Curve')
    plt.legend()
    plt.xlabel('M [M_sun / h]')
    plt.ylabel('Formation Age Lookback time [Gyr]')
    ##Create Second x axis
    xlims = plt.xlim()
    x2 = plt.twiny()
    x2.set_xscale('log')
    x2.set_xlim((xlims[0] / .73, xlims[1] / .73))
    x2.set_xlabel('M [M_sun]')
    
    ##Create second y axis
    
    ylims = plt.ylim()
    yt = plt.yticks()[0]
    y2 = plt.twinx()
    y2.set_ylim(ylims)
    y2.set_yticks(yt)
    yl = []
    for j in yt:
        if j < 13.5795:
            yl.append('{:5.2f}'.format(1.44224957031 / mth.sinh(0.0969815 * (13.5795 - j))**(2./3.)))
        else:
            yl.append('')
    y2.set_yticklabels(yl)
    y2.set_ylabel('z + 1')
开发者ID:jpwalker,项目名称:age-clustering,代码行数:34,代码来源:Mass_vs_age.py

示例6: plotBoundaries

def plotBoundaries (tranNames, blocks):
    '''Plot exon boundaries as vertical lines.'''

    ticksStart  = list()     # x-axis tick positions in phony space
    ticksEnd    = list()
    labelsStart = list()     # x-axis labels are real genomic coordinates of block start
    labelsEnd   = list()

    tickSep = blocks[-1].boundary / MAX_LABELS     # separation required to avoid label overlap

    frompos = 0
    for bound in blocks:

        plt.vlines (bound.boundary, 0, len(tranNames)+1, linewidth=0.5, colors='red')    # block boundary

        if not bound.annot:            # if block does not include annotation exon(s), make it blush
            plt.axvspan(frompos, bound.boundary, facecolor='Pink', alpha=0.4)

        if len(ticksStart) == 0 or frompos - ticksStart[-1] > tickSep:     # add tick only if there's room for the label
            ticksStart.append(frompos)
            labelsStart.append(str(bound.start))
        if len(ticksEnd) == 0 or bound.boundary - ticksEnd[-1] > tickSep:
            ticksEnd.append(bound.boundary)
            labelsEnd.append(str(bound.end))

        frompos = bound.boundary           # new block start

    numberedNames = list()                 # cluster name + line number
    for ix, name in enumerate(tranNames):
        numberedNames.append('%s %3d' % (name, ix+1))

    plt.grid(axis='y')                     # turn on horizontal dotted lines
    plt.xlim (0, blocks[-1].boundary)
    plt.ylim (len(tranNames)+1, 0)
    plt.xticks (ticksStart, labelsStart, fontsize='xx-small')
    plt.yticks (xrange(1,len(tranNames)+2), numberedNames, fontsize='xx-small')

    # These lines came from an obscure posting on StackOverflow. They
    # create a second X axis at the bottom of the figure. I haven't
    # got a clue how they work, but they do.

    x2 = plt.twiny()
    x2.set_frame_on(True)
    x2.patch.set_visible(False)
    x2.xaxis.set_ticks_position('bottom')
    x2.xaxis.set_label_position('bottom')
    x2.spines['bottom'].set_position(('outward', 20))

    plt.axes(x2)

    plt.grid(axis='y')
    plt.xlim (0, blocks[-1].boundary)
    plt.ylim (len(tranNames)+1, 0)
    plt.xticks (ticksEnd, labelsEnd, fontsize='xx-small')
    plt.yticks (xrange(1,len(tranNames)+2), numberedNames, fontsize='xx-small')

    return
开发者ID:JasperYH,项目名称:MatchAnnot,代码行数:57,代码来源:clusterView.py

示例7: plotPatternBeyondRepeat

def plotPatternBeyondRepeat(genomeSource1,genomeSource2,  start1,  start2, plotRange):
    f1 = open(genomeSource1,'r')
    f2 = open(genomeSource2,'r')
    
    pointerLocation1 = start1
    pointerLocation2 = start2
    
    windowSize = 10
    
    defaultsize = 24
    distanceList = []
    plotRange = plotRange/windowSize
    
    for index in range(plotRange):
        f1.seek(pointerLocation1)
        f2.seek(pointerLocation2)
    
        str1 = f1.read(windowSize)
        str2 = f2.read(windowSize)
        
        pointerLocation1 = pointerLocation1 + windowSize
        pointerLocation2 = pointerLocation2 + windowSize
        
        distance = hammingDistance(str1, str2, min(windowSize,len(str1),len(str2)))
        distanceList.append(distance)        
        
    
    #plt.subplot(111)
    plt.plot(range(0,len(distanceList)*windowSize, windowSize), distanceList)
    
    plt.tick_params(axis='both', which='major', labelsize=defaultsize)
    plt.tick_params(axis='both', which='minor', labelsize=defaultsize)
    
    plt.xlabel("Genomics location of Copy 1 ( unit : base )", fontsize=defaultsize)    
    plt.ylabel("Hamming distance within a window of length 10 ",fontsize=defaultsize)
    
    #print plt.xticks()
    locs =range(0,len(distanceList)*windowSize+1, len(distanceList)*windowSize/4)
    tick_lbls =  range(start1, start1+plotRange*windowSize+1, plotRange*windowSize/4)
    plt.xticks(locs, tick_lbls, fontsize=defaultsize)
    
    ax2 = plt.twiny()
    plt.tick_params(axis='both', which='major', labelsize=defaultsize)
    plt.tick_params(axis='both', which='minor', labelsize=defaultsize)
    
    plt.xlabel("Genomics location of Copy 2 ( unit : base )", fontsize=defaultsize)    
    plt.ylabel("Hamming distance within a window of length 10 ",fontsize=defaultsize)
    
    tick_locs = range(0, plotRange*windowSize+1, plotRange*windowSize/4)
    tick_lbls = range(start2, start2+plotRange*windowSize+1, plotRange*windowSize/4)
    plt.xticks(tick_locs, tick_lbls,fontsize=defaultsize)
  
    plt.show()

    f1.close()
    f2.close()
开发者ID:AdventureCompBio,项目名称:approxRepeats,代码行数:56,代码来源:slidePlot.py

示例8: make_twiny

def make_twiny(offset):
    """
    """
    
    ax3 = plt.twiny()
    ax3.xaxis.set_ticks_position('bottom')
    ax3.spines['bottom'].set_position(('axes',-offset))
    ax3.set_frame_on(True)
    ax3.patch.set_visible(False)
    ax3.spines["bottom"].set_visible(True)
    
    return ax3
开发者ID:akelbert,项目名称:mtpy,代码行数:12,代码来源:pek1dplotting.py

示例9: case_three

def case_three(filename):
    with open(filename) as f:
        data = map(lambda line: map(int, line.split(',')), f.readlines())

    plots = {}
    for d in data:
        lock = d[3]
        if lock in plots:
            plots[lock][0].append(d[2])  # c
            plots[lock][1].append(d[4])  # time
        else:
            plots[lock] = [[d[2]], [d[4]]]

    for (lock, (x, y)) in plots.items():
        if lock == 1:
            lock_name = 'Pthread Mutex Lock'
        elif lock == 2:
            lock_name = 'Pthread Spin Lock'
        elif lock == 3:
            lock_name = 'TAS Spin Lock'
        elif lock == 4:
            lock_name = 'TTAS Spin Lock'
        elif lock == 5:
            lock_name = 'Exponential Backoff Lock'
        else:
            lock_name = 'Queue Lock'
        pyplot.plot(range(len(x)), y, label='%s' % lock_name)

    pyplot.legend(loc='best')
    pyplot.xticks(range(11), (1000, 900, 800, 700, 600, 500, 400, 300, 200, 100, 0))
    pyplot.xlabel('Operations Inside Critical Section')
    pyplot.twiny()
    pyplot.xticks(range(11), (0, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000))
    pyplot.xlabel('Operations Outside Critical Section')
    pyplot.ylabel('Running Time (ms)')
    pyplot.savefig('case_three.png')
    pyplot.clf()
开发者ID:YansongZang,项目名称:cmpt-886,代码行数:37,代码来源:plot.py

示例10: labelnai

def labelnai(color='gray', zorder=1, twins=True, **kwargs):
    importmpl()
    import gbm
    for (i, (detp, dett)) in enumerate(gbm.naipt.T):
        plt.text(detp, dett, gbm.nlist[i], horizontalalignment='center', verticalalignment='center', color=color, zorder=zorder, *kwargs)
    plt.xlabel(r'spacecraft $\phi$ [rad]')
    plt.ylabel(r'spacecraft $\theta$ [rad]')
    # plt.subplots_adjust(top=0.875)
    plt.setp(plt.gca(), xlim=[0, 2*np.pi], ylim=[np.pi, 0])
    plt.gca().xaxis.tick_bottom()
    plt.gca().yaxis.tick_left()
    if twins:
        ax2 = plt.twinx()
        plt.setp(ax2, ylim=[180, 0])
        ay2 = plt.twiny()
        plt.setp(ay2, xlim=[0, 360])
开发者ID:lindyblackburn,项目名称:gbuts,代码行数:16,代码来源:plots.py

示例11: setup_axes

    def setup_axes(self):
        self.ax = plt.subplot(111)

        # Second Y axis on the right for the ZHR 
        self.ax_zhr = plt.twinx(ax=self.ax)
        self.ax_zhr.set_ylabel("ZHR (r={0:.1f}, $\gamma$={1:.2f})".format(
                                                self.profile.popindex,
                                                self.profile.gamma))
        self.ax_zhr.yaxis.set_major_formatter(plt.FuncFormatter(self.zhr_formatter))
        
        # Second X axis as top for the solar longitude
        self.ax2 = plt.twiny(ax=self.ax)
        self.ax2.set_xlabel("Solar longitude (J2000.0)")
        self.ax2.xaxis.set_major_formatter(plt.FuncFormatter(self.sollon_formatter))
          
        self.ax.grid(which="both")
开发者ID:barentsen,项目名称:meteor-flux,代码行数:16,代码来源:graph.py

示例12: _create_figure

 def _create_figure():
     # create the figure with four subplots with different size
     # - 1st is for the predominant melody and performed notes
     # - 2nd is the pitch distribution and note models, it shares the y
     # axis with the 1st
     # - 3rd is the melodic progression, it shares the x axis with the 1st
     # - 4th is for the sections, it is on top the 3rd
     fig = plt.figure()
     gs = gridspec.GridSpec(2, 2, width_ratios=[6, 1], height_ratios=[4, 1])
     ax1 = fig.add_subplot(gs[0])  # pitch and notes
     ax2 = fig.add_subplot(gs[1], sharey=ax1)  # pitch dist. and note models
     ax4 = fig.add_subplot(gs[2])  # sections
     ax5 = fig.add_subplot(gs[3])  # makam, tempo, tonic, ahenk annotations
     ax3 = plt.twiny(ax4)  # melodic progression
     ax1.get_shared_x_axes().join(ax1, ax3)
     fig.subplots_adjust(hspace=0, wspace=0)
     return fig, ax1, ax2, ax3, ax4, ax5
开发者ID:sertansenturk,项目名称:tomato,代码行数:17,代码来源:plotter.py

示例13: main

def main():


	plt.figure(figsize=(6, 5), dpi=80)
	
	wyk1 = plt.subplot(121)
	
	rysowanie('rsel.csv', 'b')
	rysowanie('cel-rs.csv', 'g')
	rysowanie('2cel-rs.csv', 'r')
	rysowanie('cel.csv', 'k')
	rysowanie('2cel.csv', 'm')  

	plt.grid(linewidth=0.5, color='grey')
	plt.axis((0,500,60,100), size="small")
	wyk1.tick_params(labelsize="small")

	plt.xlabel('Rozegranych gier (x1000)', size="small")
	plt.ylabel('Odsetek wygranych gier [%]', size="small")	

	legenda = plt.legend(['1-Evol-RS','1-Coev-RS','2-Coev-RS','1-Coev','2-Coev'], loc="lower right", prop={'size':'x-small'}, fancybox=True)

	legenda.get_frame().set_alpha(0.75)
	legenda.get_frame().set_linewidth(0.5)

	wyk2 = plt.twiny()
	plt.axis([0,200,60,100], size="small")
	wyk2.set_xticks([0,40,80,120,160,200])
	wyk2.tick_params(labelsize="small")
	plt.xlabel('Pokolenie', size="small")


	names_list=['1-Evol-RS','1-Coev-RS','2-Coev-RS','1-Coev','2-Coev']
	
	plt.subplot(122)
	#plt.boxplot(box_list, notch = True, labels = names_list, showmeans=True, meanprops=dict(marker='o'))
	frame = plt.gca()
	plt.grid()
	frame.axes.get_yaxis().set_visible(False)
	plt.twinx()
	plt.grid()
	plt.axis([0,6,60,100])
	
	
	plt.savefig('myplot.jpg')
	plt.close()
开发者ID:dakolech,项目名称:University-Human-Computer-Interaction,代码行数:46,代码来源:wizualizacja.py

示例14: draw_left

def draw_left(m_list, ox_list, series):
    s1 = plt.subplot(1, 2, 1)
    [i.set_linewidth(0.5) for i in s1.spines.itervalues()]
    plt.xlim(xmax=500)
    plt.axis(siez='small')
    plt.grid(True, alpha=0.5, linewidth=0.3)
    plt.tick_params(labelsize='x-small')
    i = 0
    for c, l, mark in series:
        plt.plot(ox_list[i], m_list[i], color=c, label=l, marker=mark, markersize=5, markevery=25, alpha=0.8)
        i += 1
    legend = plt.legend(loc = 'lower right', framealpha=0.5, fontsize='small', fancybox=True, prop={'size': 'x-small'})
    legend.get_frame().set_linewidth(0.5)
    plt.xlabel('Rozegranych gier ($\\times$ 1000)', size='x-small')
    plt.ylabel('Odsetek wygranych gier [$\%$]', size='x-small')
    s2 = plt.twiny()
    plt.xlabel('Pokolenie', size='x-small')
    s2.set_xticks([0, 40, 80, 120, 160, 200])
    s2.tick_params(labelsize='x-small')
开发者ID:gracz21,项目名称:KCK,代码行数:19,代码来源:Projekt_1.py

示例15: figure1

 def figure1(self, count=50):
   tha = self.theta_a
   thc = self.theta_c
   plt.xlabel(r'$t_c \mathrm{[nm]}$', size=15)
   plt.ylabel(r'$I_a/I_c$', size=15)
   plt.ylim(0, 60)
   plt.text(0.05, 50,
            '$T_{\mathrm{Fix}}=$'+str(self.T)+' $\mathrm{nm}$',
            horizontalalignment='left',
            verticalalignment='bottom',
            fontsize=20)
   ta = np.linspace(0, self.T, count)
   x = ta
   y = []
   for t1 in ta:
     val = self._get_I(t1, self.T-t1, tha, thc)
     y.append(val)
   plt.plot(x, y)
   ax = plt.twiny()
   ax.set_xlabel(r'$t_a \mathrm{[nm]}$', size=15)
   ax.set_xlim(self.T, 0)
   plt.show()
开发者ID:soma0sd,项目名称:python-study,代码行数:22,代码来源:integrations2.py


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