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


Python pyplot.stem方法代码示例

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


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

示例1: plot

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import stem [as 别名]
def plot(self, x, *args, **kwds):

        clip_lower, kwds = self._get_clip_lower(kwds)
        mass = self.pdf(clip_lower, *args, **kwds)
        xr = np.concatenate(([clip_lower+1e-6], x[x>clip_lower]))
        import matplotlib.pyplot as plt
        #x = np.linspace(-4, 4, 21)
        #plt.figure()
        plt.xlim(clip_lower-0.1, x.max())
        #remove duplicate calculation
        xpdf = self.pdf(x, *args, **kwds)
        plt.ylim(0, max(mass, xpdf.max())*1.1)
        plt.plot(xr, self.pdf(xr, *args, **kwds))
        #plt.vline(clip_lower, self.pdf(clip_lower, *args, **kwds))
        plt.stem([clip_lower], [mass],
                 linefmt='b-', markerfmt='bo', basefmt='r-')
        return 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:19,代码来源:otherdist.py

示例2: _stem

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import stem [as 别名]
def _stem(self, plot_kwargs=None, figure_kwargs=None, **kwargs):
        """
        Function to create a stem plot and push it

        Parameters
        ----------
        plot_kwargs : dict
            the arguments for plotting
        figure_kwargs : dict
            the arguments to actually create the figure
        **kwargs :
            additional keyword arguments for pushing the created figure to the
            logging writer

        """
        if figure_kwargs is None:
            figure_kwargs = {}
        if plot_kwargs is None:
            plot_kwargs = {}
        with self.FigureManager(self._figure, figure_kwargs, kwargs):
            from matplotlib.pyplot import stem
            stem(**plot_kwargs) 
开发者ID:delira-dev,项目名称:delira,代码行数:24,代码来源:base_backend.py

示例3: plot_and_save

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import stem [as 别名]
def plot_and_save(self, mu_all: torch.Tensor, output_name: str = None):
        """
        Plot the stem plot of exogenous intensity functions for all event types
        Args:
        :param mu_all: a (num_type, 1) FloatTensor containing all exogenous intensity functions
        :param output_name: the name of the output png file
        """
        mu_all = mu_all.squeeze(1)  # (C,)
        mu_all = mu_all.data.cpu().numpy()

        plt.figure(figsize=(5, 5))
        plt.stem(range(mu_all.shape[0]), mu_all, '-')
        plt.ylabel('Exogenous intensity')
        plt.xlabel('Index of event type')
        if output_name is None:
            plt.savefig('exogenous_intensity.png')
        else:
            plt.savefig(output_name)
        plt.close("all")
        logger.info("Done!") 
开发者ID:HongtengXu,项目名称:PoPPy,代码行数:22,代码来源:ExogenousIntensity.py

示例4: _plot_item

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import stem [as 别名]
def _plot_item(W, name, full_name, nspaces):
  plt.figure()
  if W.shape == ():
    print(name, ": ", W)
  elif W.shape[0] == 1:
    plt.stem(W.T)
    plt.title(full_name)
  elif W.shape[1] == 1:
    plt.stem(W)
    plt.title(full_name)
  else:
    plt.imshow(np.abs(W), interpolation='nearest', cmap='jet');
    plt.colorbar()
    plt.title(full_name) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:16,代码来源:plot_lfads.py

示例5: plot_priors

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import stem [as 别名]
def plot_priors():
  g0s_prior_mean_bxn = train_modelvals['prior_g0_mean']
  g0s_prior_var_bxn = train_modelvals['prior_g0_var']
  g0s_post_mean_bxn = train_modelvals['posterior_g0_mean']
  g0s_post_var_bxn = train_modelvals['posterior_g0_var']

  plt.figure(figsize=(10,4), tight_layout=True);
  plt.subplot(1,2,1)
  plt.hist(g0s_post_mean_bxn.flatten(), bins=20, color='b');
  plt.hist(g0s_prior_mean_bxn.flatten(), bins=20, color='g');

  plt.title('Histogram of Prior/Posterior Mean Values')
  plt.subplot(1,2,2)
  plt.hist((g0s_post_var_bxn.flatten()), bins=20, color='b');
  plt.hist((g0s_prior_var_bxn.flatten()), bins=20, color='g');
  plt.title('Histogram of Prior/Posterior Log Variance Values')

  plt.figure(figsize=(10,10), tight_layout=True)
  plt.subplot(2,2,1)
  plt.imshow(g0s_prior_mean_bxn.T, interpolation='nearest', cmap='jet')
  plt.colorbar(fraction=0.025, pad=0.04)
  plt.title('Prior g0 means')

  plt.subplot(2,2,2)
  plt.imshow(g0s_post_mean_bxn.T, interpolation='nearest', cmap='jet')
  plt.colorbar(fraction=0.025, pad=0.04)
  plt.title('Posterior g0 means');

  plt.subplot(2,2,3)
  plt.imshow(g0s_prior_var_bxn.T, interpolation='nearest', cmap='jet')
  plt.colorbar(fraction=0.025, pad=0.04)
  plt.title('Prior g0 variance Values')

  plt.subplot(2,2,4)
  plt.imshow(g0s_post_var_bxn.T, interpolation='nearest', cmap='jet')
  plt.colorbar(fraction=0.025, pad=0.04)
  plt.title('Posterior g0 variance Values')

  plt.figure(figsize=(10,5))
  plt.stem(np.sort(np.log(g0s_post_mean_bxn.std(axis=0))));
  plt.title('Log standard deviation of h0 means'); 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:43,代码来源:plot_lfads.py

示例6: _periodogram_plot

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import stem [as 别名]
def _periodogram_plot(title, column, data, trend, peaks):
    """display periodogram results using matplotlib"""

    periods, power = periodogram(data)
    plt.figure(1)
    plt.subplot(311)
    plt.title(title)
    plt.plot(data, label=column)
    if trend is not None:
        plt.plot(trend, linewidth=3, label="broad trend")
        plt.legend()
        plt.subplot(312)
        plt.title("detrended")
        plt.plot(data - trend)
    else:
        plt.legend()
        plt.subplot(312)
        plt.title("(no detrending specified)")
    plt.subplot(313)
    plt.title("periodogram")
    plt.stem(periods, power)
    for peak in peaks:
        period, score, pmin, pmax = peak
        plt.axvline(period, linestyle='dashed', linewidth=2)
        plt.axvspan(pmin, pmax, alpha=0.2, color='b')
        plt.annotate("{}".format(period), (period, score * 0.8))
        plt.annotate("{}...{}".format(pmin, pmax), (pmin, score * 0.5))
    plt.tight_layout()
    plt.show() 
开发者ID:welch,项目名称:seasonal,代码行数:31,代码来源:application.py

示例7: main

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import stem [as 别名]
def main(streaming):
    modes, evals = streaming_dmd() if streaming else standard_dmd()
    fdmd = np.abs(np.angle(evals)) / (2 * np.pi * dt)
    n_modes = len(fdmd)
    ydmd = np.zeros(n_modes)
    for i in range(n_modes):
        ydmd[i] = np.linalg.norm(modes[:, i] * np.abs(evals[i]))
    ydmd /= max(ydmd)
    plt.stem(fdmd, ydmd)
    plt.show() 
开发者ID:cwrowley,项目名称:dmdtools,代码行数:12,代码来源:streaming_dmd_example.py

示例8: ex6_2

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import stem [as 别名]
def ex6_2(n):
    """
    Generate a triangle pulse as described in Example 6-2
    of Chapter 6.
    
    You need to supply an index array n that covers at least [-2, 5]. 
    The function returns the hard-coded signal of the example.
    
    Parameters
    ----------
    n : time index ndarray covering at least -2 to +5.
    
    Returns
    -------
    x : ndarray of signal samples in x
    
    Examples
    --------
    >>> import numpy as np
    >>> import matplotlib.pyplot as plt
    >>> from sk_dsp_comm import sigsys as ss
    >>> n = np.arange(-5,8)
    >>> x = ss.ex6_2(n)
    >>> plt.stem(n,x) # creates a stem plot of x vs n
    """
    x = np.zeros(len(n))
    for k, nn in enumerate(n):
        if nn >= -2 and nn <= 5:
            x[k] = 8 - nn
    return x 
开发者ID:mwickert,项目名称:scikit-dsp-comm,代码行数:32,代码来源:sigsys.py

示例9: dimpulse

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import stem [as 别名]
def dimpulse(n):
    """
    Discrete impulse function delta[n].
    
    Parameters
    ----------
    n : ndarray of the time axis
    
    Returns
    -------
    x : ndarray of the signal delta[n]
    
    Examples
    --------
    >>> import matplotlib.pyplot as plt
    >>> from numpy import arange
    >>> from sk_dsp_comm.sigsys import dimpulse
    >>> n = arange(-5,5)
    >>> x = dimpulse(n)
    >>> plt.stem(n,x)
    >>> plt.show()

    Shift the delta left by 2.

    >>> x = dimpulse(n+2)
    >>> plt.stem(n,x)
    """
    x = np.zeros(len(n))
    for k,nn in enumerate(n):
        if nn == 0:
            x[k] = 1.0
    return x 
开发者ID:mwickert,项目名称:scikit-dsp-comm,代码行数:34,代码来源:sigsys.py

示例10: dstep

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import stem [as 别名]
def dstep(n):
    """
    Discrete step function u[n].
    
    Parameters
    ----------
    n : ndarray of the time axis
    
    Returns
    -------
    x : ndarray of the signal u[n]
    
    Examples
    --------
    >>> import matplotlib.pyplot as plt
    >>> from numpy import arange
    >>> from sk_dsp_comm.sigsys import dstep
    >>> n = arange(-5,5)
    >>> x = dstep(n)
    >>> plt.stem(n,x)
    >>> plt.show()

    Shift the delta left by 2.

    >>> x = dstep(n+2)
    >>> plt.stem(n,x)
    """
    x = np.zeros(len(n))
    for k,nn in enumerate(n):
        if nn >= 0:
            x[k] = 1.0
    return x 
开发者ID:mwickert,项目名称:scikit-dsp-comm,代码行数:34,代码来源:sigsys.py

示例11: plot_na

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import stem [as 别名]
def plot_na(x,y,mode='stem'):
    pylab.figure(figsize=(5,2))
    frame1 = pylab.gca()
    if mode.lower() == 'stem':
         pylab.stem(x,y)
    else:
        pylab.plot(x,y)
    
    frame1.axes.get_xaxis().set_visible(False)
    frame1.axes.get_yaxis().set_visible(False) 
    pylab.show() 
开发者ID:mwickert,项目名称:scikit-dsp-comm,代码行数:13,代码来源:sigsys.py

示例12: main

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import stem [as 别名]
def main(_):

    print('\n\n%s\n\n' % hyperparams.shortString())

    _, _, stats, _, _ = cache.getOrEval()

    frequencies = np.zeros(128)
    for i in range(128):
        frequencies[i] = np.mean(stats[stats[:, 0] == i, 2])

    # Inlierness over channel
    plt.figure(0, figsize=[5, 2.5])
    plt.stem(frequencies)
    plt.xlabel('Channel #')
    plt.ylim(ymin=0)
    plt.ylabel('Inlier frequency')
    plt.tight_layout()
    ax = plt.axes()
    ax.yaxis.grid()
    plt.show()

    # Inlierness VS prediction
    num_bins = 20
    bins = [[] for _ in range(num_bins)]
    for row in range(stats.shape[0]):
        index = int(stats[row, 1] * num_bins)
        bins[index].append(stats[row, 2])

    bin_frequencies = np.array([np.mean(bin_) for bin_ in bins])

    counts = np.array([len(bin_) for bin_ in bins])

    bin_width = float(1) / num_bins

    fig, ax1 = plt.subplots(figsize=[5, 2.5])
    ax1.hlines(bin_frequencies, bin_width * np.arange(num_bins),
               bin_width * (np.arange(num_bins) + 1), colors='red', linewidth=3)
    ax1.set_xlabel('Response')
    ax1.set_ylabel('Inlierness frequency', color='r')
    ax1.grid()
    ax1.set_xlim([0, 1])

    ax2 = ax1.twinx()
    ax2.set_ylabel('# points with given prediction', color='b')
    ax2.stem(bin_width * (np.arange(num_bins) + 0.5), counts, color='b',
             basefmt='')
    print(counts)
    ax2.set_ylim(bottom=0)
    ax1.set_ylim(bottom=0)
    plt.tight_layout()

    plt.show() 
开发者ID:uzh-rpg,项目名称:imips_open,代码行数:54,代码来源:plot_analysis.py

示例13: ten_band_eq_resp

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import stem [as 别名]
def ten_band_eq_resp(GdB,Q=3.5):
    """
    Create a frequency response magnitude plot in dB of a ten band equalizer
    using a semilogplot (semilogx()) type plot
    
    
    Parameters
    ----------
    GdB : Gain vector for 10 peaking filters [G0,...,G9]
    Q : Quality factor for each peaking filter (default 3.5)
    
    Returns
    -------
    Nothing : two plots are created
    
    Examples
    --------
    >>> import matplotlib.pyplot as plt
    >>> from sk_dsp_comm import sigsys as ss
    >>> ss.ten_band_eq_resp([0,10.0,0,0,-1,0,5,0,-4,0])
    >>> plt.show()
    """
    fs = 44100.0 # Hz
    NB = len(GdB)
    if not NB == 10:
        raise ValueError("GdB length not equal to ten")
    Fc = 31.25*2**np.arange(NB)
    B = np.zeros((NB,3));
    A = np.zeros((NB,3));
    
    # Create matrix of cascade coefficients
    for k in range(NB):
        b,a = peaking(GdB[k],Fc[k],Q,fs)
        B[k,:] = b
        A[k,:] = a
    # Create the cascade frequency response
    F = np.logspace(1,np.log10(20e3),1000)
    H = np.ones(len(F))*np.complex(1.0,0.0)
    for k in range(NB):
       w,Htemp = signal.freqz(B[k,:],A[k,:],2*np.pi*F/fs)
       H *= Htemp
    plt.figure(figsize=(6,4))
    plt.subplot(211)
    plt.semilogx(F,20*np.log10(abs(H)))
    plt.axis([10, fs/2, -12, 12])
    plt.grid()
    plt.title('Ten-Band Equalizer Frequency Response')
    plt.xlabel('Frequency (Hz)')
    plt.ylabel('Gain (dB)')
    plt.subplot(212)
    plt.stem(np.arange(NB),GdB,'b','bs')
    #plt.bar(np.arange(NB)-.1,GdB,0.2)
    plt.axis([0, NB-1, -12, 12])
    plt.xlabel('Equalizer Band Number')
    plt.ylabel('Gain Set (dB)')
    plt.grid() 
开发者ID:mwickert,项目名称:scikit-dsp-comm,代码行数:58,代码来源:sigsys.py

示例14: drect

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import stem [as 别名]
def drect(n,N):
    """
    Discrete rectangle function of duration N samples.
    
    The signal is active on the interval 0 <= n <= N-1. Also known
    as the rectangular window function, which is available in 
    scipy.signal.
    
    Parameters
    ----------
    n : ndarray of the time axis
    N : the pulse duration
    
    Returns
    -------
    x : ndarray of the signal
    
    Notes
    -----
    The discrete rectangle turns on at n = 0, off at n = N-1 and 
    has duration of exactly N samples.
    
    Examples
    --------
    >>> import matplotlib.pyplot as plt
    >>> from numpy import arange
    >>> from sk_dsp_comm.sigsys import drect
    >>> n = arange(-5,5)
    >>> x = drect(n, N=3)
    >>> plt.stem(n,x)
    >>> plt.show()

    Shift the delta left by 2.

    >>> x = drect(n+2, N=3)
    >>> plt.stem(n,x)
    """ 
    x = np.zeros(len(n))
    for k,nn in enumerate(n):
        if nn >= 0 and nn < N:
            x[k] = 1.0
    return x 
开发者ID:mwickert,项目名称:scikit-dsp-comm,代码行数:44,代码来源:sigsys.py

示例15: sqrt_rc_imp

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import stem [as 别名]
def sqrt_rc_imp(Ns,alpha,M=6):
    """
    A truncated square root raised cosine pulse used in digital communications.

    The pulse shaping factor 0< alpha < 1 is required as well as the 
    truncation factor M which sets the pulse duration to be 2*M*Tsymbol.
     

    Parameters
    ----------
    Ns : number of samples per symbol
    alpha : excess bandwidth factor on (0, 1), e.g., 0.35
    M : equals RC one-sided symbol truncation factor

    Returns
    -------
    b : ndarray containing the pulse shape

    Notes
    -----
    The pulse shape b is typically used as the FIR filter coefficients
    when forming a pulse shaped digital communications waveform. When 
    square root raised cosine (SRC) pulse is used generate Tx signals and 
    at the receiver used as a matched filter (receiver FIR filter), the 
    received signal is now raised cosine shaped, this having zero 
    intersymbol interference and the optimum removal of additive white 
    noise if present at the receiver input.

    Examples
    --------
    >>> # ten samples per symbol and alpha = 0.35
    >>> import matplotlib.pyplot as plt
    >>> from numpy import arange
    >>> from sk_dsp_comm.sigsys import sqrt_rc_imp
    >>> b = sqrt_rc_imp(10,0.35)
    >>> n = arange(-10*6,10*6+1)
    >>> plt.stem(n,b)
    >>> plt.show()
    """
    # Design the filter
    n = np.arange(-M*Ns,M*Ns+1)
    b = np.zeros(len(n))
    Ns *= 1.0
    a = alpha
    for i in range(len(n)):
       if abs(1 - 16*a**2*(n[i]/Ns)**2) <= np.finfo(np.float).eps/2:
           b[i] = 1/2.*((1+a)*np.sin((1+a)*np.pi/(4.*a))-(1-a)*np.cos((1-a)*np.pi/(4.*a))+(4*a)/np.pi*np.sin((1-a)*np.pi/(4.*a)))
       else:
           b[i] = 4*a/(np.pi*(1 - 16*a**2*(n[i]/Ns)**2))
           b[i] = b[i]*(np.cos((1+a)*np.pi*n[i]/Ns) + np.sinc((1-a)*n[i]/Ns)*(1-a)*np.pi/(4.*a))
    return b 
开发者ID:mwickert,项目名称:scikit-dsp-comm,代码行数:53,代码来源:sigsys.py


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