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

Python pylab.stem函数代码示例

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

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



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

示例1: plot

    def plot(self, marker='o', color='red', m=0, M=6000):
        """Plots the position / height of the peaks in the well

        .. plot::
            :include-source:

            from fragment_analyser import Line, fa_data
            l = Line(fa_data("alternate/peaktable.csv"))
            well = l.wells[0]
            well.plot()

        """
        import pylab
        if len(self.df) == 0:
            print("Nothing to plot (no peaks)")
            return
        x = self.df['Size (bp)'].astype(float).values
        y = self.df['RFU'].astype(float).values

        pylab.stem(x, y, marker=marker, color=color)
        pylab.semilogx()
        pylab.xlim([1, M])
        pylab.ylim([0, max(y)*1.2])
        pylab.grid(True)
        pylab.xlabel("size (bp)")
        pylab.ylabel("RFU")
        return x, y
开发者ID:C3BI-pasteur-fr,项目名称:FragmentAnalyser,代码行数:27,代码来源:well.py


示例2: plot_weights

 def plot_weights(self):
     import pylab
     x, w = zip(*self.distribution)
     pylab.stem(x, 100*numpy.array(w))
     pylab.title('Weight distribution')
     pylab.xlabel(self.P.name)
     pylab.ylabel('Percentage')
开发者ID:reflectometry,项目名称:refl1d,代码行数:7,代码来源:dist.py


示例3: display_fit

def display_fit(xs, target, method, color=None, acronym=None, xmax=None, linewidth=2):
    if not hasattr(method, "__iter__"):
        method = (method,)
        if not color is None:
            color = (color,)
        if not acronym is None:
            acronym = (acronym,)
    if not xs.shape[0] == 1:
        raise ValueError("univariate data expected")
    if xmax == None:
        xmax = int(np.max(np.abs(xs.squeeze()))) + 1
    x = np.linspace(-xmax, xmax, 2 * xmax / 0.01)
    x = np.reshape(x, (1, x.size))
    fits = [m.fit(x) for m in method]
    if color is None:
        for fit in fits:
            plt.plot(x.squeeze(), fit, linewidth=linewidth)
    else:
        for fit, col in zip(fits, color):
            plt.plot(x.squeeze(), fit, col, linewidth=linewidth)
    if not acronym is None:
        plt.legend(acronym)
    target_xs = np.exp(target(xs.squeeze()))
    target_x = np.exp(target(x.squeeze()))
    plt.stem(xs.squeeze(), target_xs, linefmt="k-", markerfmt="ko", basefmt="k-")
    plt.plot(x.squeeze(), target_x, "k")
    x0, x1, y0, y1 = plt.axis()
    plt.plot((x0, x1), (0, 0), "k")
    plt.show()
开发者ID:alexis-roche,项目名称:variational_sampler,代码行数:29,代码来源:display.py


示例4: matlab_fourier_anal

def matlab_fourier_anal(data, sample_rate = 1.0):
 
  n = data.shape[0] 
  t = np.arange(n)

  P.figure()
  P.plot(t/sample_rate,data)
  P.xlabel('Time Units')
  P.ylabel('Data Magnitude')

  Y = fftpack.fft(data);
  freqs = np.arange(n/2.0) * sample_rate / n  
  power = np.abs(Y[:n/2.0])

  P.figure()
  markerline, stemlines, baseline = P.stem(freqs, power, '--')
  P.setp(markerline, 'markerfacecolor', 'b')
  # P.setp(baseline, 'color','r', 'linewidth', 2)
  P.xlabel('Cycles/ Unit Time')
  P.ylabel('Power')
  P.title('Periodogram')

  period = 1. / freqs
  
  k = np.arange(50)
  f = k / float(n)
  power2 = power[k];

  P.figure()
  markerline, stemlines, baseline = P.stem(f, power2, '--')
  P.setp(markerline, 'markerfacecolor', 'b')
  P.setp(baseline, 'color','r', 'linewidth', 2)
  P.xlabel('Unit Time / Cycle')
  P.ylabel('Power')
  P.title('Periodogram: First 50 periods')
开发者ID:MrKriss,项目名称:Old-PhD-Code,代码行数:35,代码来源:Fourier_Analysis.py


示例5: plot_reflection

 def plot_reflection(self):
     from pylab import stem, title, xlabel, ylabel
     if self.reflection is not None:
         stem(list(range(0, len(self.reflection))), abs(self.reflection))
         title('Reflection coefficient evolution')
         xlabel('Order')
         ylabel('Reflection Coefficient absolute values')
     else:
         logging.warning("Reflection coefficients not available or not yet computed.")
开发者ID:cokelaer,项目名称:spectrum,代码行数:9,代码来源:psd.py


示例6: decode_symbols

def decode_symbols(r, i, corr_index, r0, i0, Nbits, fs=48000, baud=300,
        plot=False):
    Ns = fs/baud
    r = r[corr_index:]
    i = i[corr_index:]

    r0 = r0[corr_index:]
    i0 = i0[corr_index:]

   #print len(r)
   #print len(r0)
   #print len(i0)

    r = r/np.max(r)*2.2 #change this 2 depending on the input amplitude
    i = i/np.max(i)*2.2 #change this 2 depending on the input amplitude

    if plot:
        fig = plt.figure(figsize = (16,4))
        plt.plot(2*r0)
        plt.plot(r)
        plt.title('Real part, raw input and normalized')

        fig = plt.figure(figsize = (16,4))
        plt.plot(2*i0)
        plt.plot(i)
        plt.title('Imaginary part, raw input and normalized')

    ####Decode
    idx = np.r_[Ns/2:len(r):Ns]

    #r = np.around(r)
    #i = np.around(i)

    r_dec = np.around(r[idx])
    i_dec = np.around(i[idx])

    if plot:
        fig = plt.figure(figsize = (16,4))
        plt.plot(2*r0)
        plt.plot(r)
        plt.plot(np.around(r))
        plt.stem(idx, r_dec)
        plt.title('Real part, decoded by sampling values as indicated')

        fig = plt.figure(figsize = (16,4))
        plt.plot(2*i0)
        plt.plot(i)
        plt.plot(np.around(i))
        plt.stem(idx, i_dec)
        plt.title('Imaginary part, decoded by sampling values as indicated')
        fig = plt.figure(figsize = (8,8))
        plt.scatter(r0*2, i0*2, c='r')
        plt.scatter(r_dec, i_dec, c='g')

        plt.title('Constellation of input message vs decoded symbols')

    return r_dec + 1j*i_dec
开发者ID:viyer,项目名称:ham_qam,代码行数:57,代码来源:qam.py


示例7: print_spectrum

def print_spectrum(spectrum, filename):
    x = spectrum.mz
    y = spectrum.intensity
    pylab.stem(x, y, markerfmt='b,')
    pylab.xlabel('m/z')
    pylab.ylabel('Transformed intensity')
    pylab.grid()
    pylab.xlim(0.95*min(x), 1.05*max(x))
    pylab.savefig(filename)
开发者ID:melodi-lab,项目名称:SGM,代码行数:9,代码来源:printspectrum.py


示例8: plot_reflection

 def plot_reflection(self):
     from pylab import stem, title, xlabel, ylabel
     if self.reflection is not None:
         stem(list(range(0, len(self.reflection))), abs(self.reflection))
         title('Reflection coefficient evolution')
         xlabel('Order')
         ylabel('Reflection Coefficient absolute values')
     else:
         import warnings
         warnings.warn("""Reflection coefficients not available with
             the current method.""")
开发者ID:carlkl,项目名称:spectrum,代码行数:11,代码来源:psd.py


示例9: plot_spectra

    def plot_spectra(self):
        """ Plots the original spectrum and the sum of cisoids.
        """

        import pylab as plt
        plt.plot(self.psd[0], self.psd[1])
        freqs = [el[0] for el in self.soc]
        ampls = [el[1] for el in self.soc]
        plt.stem(freqs, ampls)
        plt.xlabel(r'$f$ in Hz')
        plt.ylabel(r'$S(f)$')
        plt.show()
开发者ID:no-net,项目名称:gr-winelo,代码行数:12,代码来源:spec2soc.py


示例10: nzcols_hist

 def nzcols_hist(P,file=None):
     if file==None: pylab.ion()
     else: pylab.ioff()
     nzcols = +P.nzcols
     Nmax = max(nzcols)
     y = matrix(0,(Nmax,1))
     for n in nzcols:
         y[n-1] += 1
     y = sparse(y)
     f = pylab.figure(); f.clf()
     pylab.stem(y.I+1,y.V)#; pylab.xlim(-1,Nmax+2)
     if file: pylab.savefig(P._pname + "_nzcols_hist.png")
开发者ID:Yuanzhang2014,项目名称:smcp,代码行数:12,代码来源:analysis.py


示例11: fourier_analysis

def fourier_analysis(sig, time_step = 1.0, top_freqs = 5, zoomed_num = 15):

  time_vec = np.arange(0, len(sig), time_step)
  
  sample_freq = fftpack.fftfreq(sig.size, d=time_step)
  
  sig_fft = fftpack.fft(sig)
  
  # Only take first half of sampling frequency 
  pidxs = np.where(sample_freq > 0)
  freqs, power = sample_freq[pidxs], np.abs(sig_fft)[pidxs]
  
  # plot with zoomed in sub plot
  P.figure()
  P.plot(freqs, power)
  P.ylabel('Power')
  P.xlabel('Frequency [Hz]')
  axes = P.axes([0.3, 0.3, 0.5, 0.5])
  P.title('Peak frequency')
  P.stem(freqs[:zoomed_num], power[:zoomed_num])
  #P.setp(axes, yticks=[])
  #P.savefig('source/fftpack-frequency.png')
  
  # Find top x frequencies to use in reconstruction 
  full_sort_idx = power.argsort()
  
  find_idx = full_sort_idx >= top_freqs 
  
  
  sorted_power = power[sort_idx][::-1] # Sort decending
  component_freqs = freqs[sort_idx[:top_freqs]]
  
  # copy fft
  reduced_sig_fft = sig_fft.copy()
  
  # set all values not in component freqs to 0 
  L = np.array(reduced_sig_fft, dtype = bool)
  L[sort_idx[:top_freqs]] = False  
  reduced_sig_fft[L] = 0
  
  # Reconstruct signal
  reconstruct_sig = fftpack.ifft(reduced_sig_fft)
  
  # Plot original and reconstructed signal 
  P.figure()
  P.plot(time_vec, sig)
  P.plot(time_vec, reconstruct_sig, linewidth=2)
  P.ylabel('Amplitude')
  P.xlabel('Time [s]')
  
  return sig_fft, reduced_sig_fft, reconstruct_sig, freqs, power, component_freqs
开发者ID:MrKriss,项目名称:Old-PhD-Code,代码行数:51,代码来源:Fourier_Analysis.py


示例12: demo

def demo(text=None):
    from nltk.corpus import brown
    import pylab
    tt=TextTilingTokenizer(demo_mode=True)
    if text is None: text=brown.raw()[:10000]
    s,ss,d,b=tt.tokenize(text)
    pylab.xlabel("Sentence Gap index")
    pylab.ylabel("Gap Scores")
    pylab.plot(range(len(s)), s, label="Gap Scores")
    pylab.plot(range(len(ss)), ss, label="Smoothed Gap scores")
    pylab.plot(range(len(d)), d, label="Depth scores")
    pylab.stem(range(len(b)),b)
    pylab.legend()
    pylab.show()
开发者ID:damorelse,项目名称:MachineTranslation,代码行数:14,代码来源:texttiling.py


示例13: plot_inflections

def plot_inflections(x,y):
    """
    Plot inflection points in the spline curve.
    """
    m = (y[2:]-y[:-2])/(x[2:]-x[:-2])
    b = y[2:] - m*x[2:]
    delta = y[1:-1] - (m*x[1:-1] + b)
    t = linspace(x[0],x[-1],400)
    import pylab
    ax1=pylab.subplot(211)
    pylab.plot(t,monospline(x,y,t),'-b',x,y,'ob')
    pylab.subplot(212, sharex=ax1)
    delta_x = x[1:-1]
    pylab.stem(delta_x,delta)
    pylab.plot(delta_x[delta<0],delta[delta<0],'og')
    pylab.axis([x[0],x[-1],min(min(delta),0),max(max(delta),0)])
开发者ID:RONNCC,项目名称:bumps,代码行数:16,代码来源:mono.py


示例14: impz

def impz(b,a=1):
  impulse = np.repeat(0.,50); impulse[0] =1.
  x = np.arange(0,50)
  response = signal.lfilter(b,a,impulse)
  pl.subplot(211)
  pl.stem(x, response)
  pl.ylabel('Amplitude') 
  pl.xlabel(r'n (samples)')
  pl.title(r'Impulse response')
  pl.subplot(212)
  step = np.cumsum(response)
  pl.stem(x, step)
  pl.ylabel('Amplitude') 
  pl.xlabel(r'n (samples)')
  pl.title(r'Step response')
  pl.subplots_adjust(hspace=0.5)
开发者ID:htlemke,项目名称:ixppy,代码行数:16,代码来源:toolsPlot.py


示例15: hist_mtx

def hist_mtx(mtx, tstr=''):
    """
    Given a piano-roll matrix, 128 MIDI piches x beats, plot the pitch class histogram
    """
    i_min, i_max = np.where(mtx.mean(1))[0][[0,-1]]
    P.figure(figsize=(14.5,8))    
    P.stem(np.arange(i_max+1-i_min),mtx[i_min:i_max+1,:].sum(1))
    ttl = 'Note Frequency'
    if tstr: ttl+=': '+tstr
    P.title(ttl,fontsize=16)
    t=P.xticks(np.arange(0,i_max+1-i_min,3),pc_labels[i_min:i_max+1:3],fontsize=14)
    P.xlabel('Pitch Class', fontsize=14)
    P.ylabel('Frequency', fontsize=14)
    ax = P.axis()
    P.axis(xmin=-0.5)
    P.grid()
开发者ID:MartinThoma,项目名称:BregmanToolkit,代码行数:16,代码来源:tonality.py


示例16: impz

def impz(b,a=1):
    l = len(b)
    impulse = numpy.repeat(0.,l); impulse[0] =1.
    x = numpy.arange(0,l)
    response = scipy.signal.lfilter(b,a,impulse)
    pylab.subplot(211)
    pylab.stem(x, response)
    pylab.ylabel('Amplitude')
    pylab.xlabel(r'n (samples)')
    pylab.title(r'Impulse response')
    pylab.subplot(212)
    step = numpy.cumsum(response)
    pylab.stem(x, step)
    pylab.ylabel('Amplitude')
    pylab.xlabel(r'n (samples)')
    pylab.title(r'Step response')
    pylab.subplots_adjust(hspace=0.5)
开发者ID:schevalier,项目名称:pyspace,代码行数:17,代码来源:test_filtering.py


示例17: plot_spectra

    def plot_spectra(self):
        """ Plots the original Spectrum and the sum of sinusoids.
        """

        import matplotlib as mp
        mp.rc('font', family='serif', size=22)
        import pylab as plt
        freqs = [f[0] for f in self.sos]
        negfreqs = [-f[0] for f in self.sos]
        # convert the amplitudes of the sinusoids to a psd
        ampls = [(a[1] / 2) ** 2 for a in self.sos]
        plt.stem(freqs, ampls)
        plt.stem(negfreqs, ampls)
        plt.xlim(1.5 * negfreqs[-1], 1.5 * freqs[-1])
        plt.ylim(0, 1.5 * max(ampls))
        plt.xlabel(r'$f$ in Hz')
        plt.ylabel(r'$\| S(f) \|$')
        plt.show()
开发者ID:no-net,项目名称:gr-winelo,代码行数:18,代码来源:spec2sos.py


示例18: impz

def impz(b,a=1):
    '''
    #Plot step and impulse response
    from http://mpastell.com/2010/01/18/fir-with-scipy/
    '''
    l = len(b)
    impulse = pylab.repeat(0.,l); impulse[0] =1.
    x = numpy.arange(0,l)
    response = signal.lfilter(b,a,impulse)
    pylab.subplot(211)
    pylab.stem(x, response)
    pylab.ylabel('Amplitude')
    pylab.xlabel(r'n (samples)')
    pylab.title(r'Impulse response')
    pylab.subplot(212)
    step = numpy.cumsum(response)
    pylab.stem(x, step)
    pylab.ylabel('Amplitude')
    pylab.xlabel(r'n (samples)')
    pylab.title(r'Step response')
    pylab.subplots_adjust(hspace=0.5)
开发者ID:wyolum,项目名称:mmM,代码行数:21,代码来源:util.py


示例19: test_volterra

def test_volterra():
    f=array([-1200.,-1000.,1000.,1200.])
    v=array([2.,2.,2.,2.])
    w=Waveform(f,v)
    v1,v2,v31,v32=lna_volterra(w)
    pylab.subplot(4,1,1)
    pylab.stem(v1.get_x()[0],v1.get_y())
    pylab.subplot(4,1,2)
    pylab.stem(v2.get_x()[0],v2.get_y())
    pylab.subplot(4,1,3)
    pylab.stem(v31.get_x()[0],v31.get_y())
    pylab.subplot(4,1,4)
    pylab.stem(v32.get_x()[0],v32.get_y())
    pylab.show()
开发者ID:AshitaPrasad,项目名称:pycircuit,代码行数:14,代码来源:volterra_example.py


示例20: _add_stems_to_plot

def _add_stems_to_plot(interval, stem_bed, samples, plot):
    stems = _get_stems_by_callers(stem_bed.tabix_intervals(interval))
    callers = sorted(stems.keys())
    caller_colormap = _get_caller_colormap(callers)
    caller_heights = _get_caller_heights(callers, plot)
    for caller in callers:
        stem_color = caller_colormap[caller]
        caller_stems = stems[caller]
        stem_heights = list(repeat(caller_heights[caller], len(caller_stems)))
        markerline, _, baseline = stem(caller_stems, stem_heights, "-.", label=caller)
        setp(markerline, "markerfacecolor", stem_color)
        setp(baseline, "color", "r", "linewidth", 0)
        plt.legend()
开发者ID:samesun,项目名称:bcbio-nextgen,代码行数:13,代码来源:coverage.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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