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


Python pylab.stem函数代码示例

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


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


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