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


Python thinkplot.plot函数代码示例

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


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

示例1: plot_bass

def plot_bass():
    wave = thinkdsp.read_wave('328878__tzurkan__guitar-phrase-tzu.wav')
    wave.normalize()
    wave.plot()

    wave.make_spectrum(full=True).plot()


    sampled = sample(wave, 4)
    sampled.make_spectrum(full=True).plot()

    spectrum = sampled.make_spectrum(full=True)
    boxcar = make_boxcar(spectrum, 4)
    boxcar.plot()

    filtered = (spectrum * boxcar).make_wave()
    filtered.scale(4)
    filtered.make_spectrum(full=True).plot()

    plot_segments(wave, filtered)


    diff = wave.ys - filtered.ys
    #thinkplot.plot(diff)
    np.mean(abs(diff))

    sinc = boxcar.make_wave()
    ys = np.roll(sinc.ys, 50)
    thinkplot.plot(ys[:100])
开发者ID:vpillajr,项目名称:ThinkDSP,代码行数:29,代码来源:sampling.py

示例2: plot_derivative

def plot_derivative(wave, wave2):
    # compute the derivative by spectral decomposition
    spectrum = wave.make_spectrum()
    spectrum3 = wave.make_spectrum()
    spectrum3.differentiate()

    # plot the derivative computed by diff and differentiate
    wave3 = spectrum3.make_wave()
    wave2.plot(color="0.7", label="diff")
    wave3.plot(label="derivative")
    thinkplot.config(xlabel="days", xlim=[0, 1650], ylabel="dollars", loc="upper left")

    thinkplot.save(root="systems4")

    # plot the amplitude ratio compared to the diff filter
    amps = spectrum.amps
    amps3 = spectrum3.amps
    ratio3 = amps3 / amps

    thinkplot.preplot(1)
    thinkplot.plot(ratio3, label="ratio")

    window = numpy.array([1.0, -1.0])
    padded = zero_pad(window, len(wave))
    fft_window = numpy.fft.rfft(padded)
    thinkplot.plot(abs(fft_window), color="0.7", label="filter")

    thinkplot.config(
        xlabel="frequency (1/days)", xlim=[0, 1650 / 2], ylabel="amplitude ratio", ylim=[0, 4], loc="upper left"
    )
    thinkplot.save(root="systems5")
开发者ID:younlonglin,项目名称:ThinkDSP,代码行数:31,代码来源:systems.py

示例3: plot_sines

def plot_sines():
    """Makes figures showing correlation of sine waves with offsets.
    """
    wave1 = make_wave(0)
    wave2 = make_wave(offset=1)

    thinkplot.preplot(2)
    wave1.segment(duration=0.01).plot(label='wave1')
    wave2.segment(duration=0.01).plot(label='wave2')

    corr_matrix = numpy.corrcoef(wave1.ys, wave2.ys, ddof=0)
    print(corr_matrix)

    thinkplot.save(root='autocorr1',
                   xlabel='time (s)',
                   ylabel='amplitude',
                   ylim=[-1.05, 1.05])


    offsets = numpy.linspace(0, PI2, 101)

    corrs = []
    for offset in offsets:
        wave2 = make_wave(offset)
        corr = corrcoef(wave1.ys, wave2.ys)
        corrs.append(corr)
    
    thinkplot.plot(offsets, corrs)
    thinkplot.save(root='autocorr2',
                   xlabel='offset (radians)',
                   ylabel='correlation',
                   xlim=[0, PI2],
                   ylim=[-1.05, 1.05])
开发者ID:jenwei,项目名称:accelerometer-interpreter,代码行数:33,代码来源:autocorr.py

示例4: CredIntPlt

def CredIntPlt(sf,kl,kh,ll,lh,house,mk,ml,Title):
	"""Given 90 credible values of k and lambda, the mean values of k and lambda, 
	the survival function, the house color scheme to use, and the plot title, this 
	function plots the 90 percent credible interval, the best line, and the data 
	we have"""

	listcol=colordict[house]
	Dark=listcol[0]
	Mid=listcol[1]
	Light=listcol[2]
	arr=np.linspace(0,7,num=100)
	weibSurv2 = exponweib.cdf(arr, kl, lh) #Lower bound
	weibSurv4 = exponweib.cdf(arr, kh, ll) #Upper bound
	weibSurv1 = exponweib.cdf(arr, mk, ml) #Best line
	p4,=plt.plot(arr, 1-weibSurv2,color=Dark,linewidth=3)
	p1,=plt.plot(arr, 1-weibSurv2,color=Light,linewidth=4)
	p2,=plt.plot(arr, 1-weibSurv1,color=Mid,linewidth=3,linestyle='--')
	p3,=plt.plot(arr, 1-weibSurv4,color=Light,linewidth=4)
	plt.fill_between(arr,1-weibSurv2,1-weibSurv4, facecolor=Light, alpha=.3)
	thinkplot.plot(sf,color=Dark)
	plt.xlabel('Age in Books')
	plt.ylabel('Probability of Survival')
	plt.ylim([0,1]) 
	
	plt.legend([p1,p2,p4],['90 Percent Credible Interval','Best Estimate','Data'])
	plt.title(Title)
开发者ID:AntonioSerrano,项目名称:bayesianGameofThrones,代码行数:26,代码来源:ASOIAF.py

示例5: plot

    def plot(self, low=0, high=None, **options):
        """Plots amplitude vs frequency.

        low: int index to start at 
        high: int index to end at
        """
        thinkplot.plot(self.fs[low:high], self.amps[low:high], **options)
开发者ID:NSasquatch,项目名称:vocoder,代码行数:7,代码来源:thinkdsp.py

示例6: plot

    def plot(self, **options):
        """Plots the wave.

        """
        n = len(self.ys)
        ts = numpy.linspace(0, self.duration, n)
        thinkplot.plot(ts, self.ys, **options)
开发者ID:benkahle,项目名称:ThinkDSP,代码行数:7,代码来源:thinkdsp.py

示例7: plot_power

    def plot_power(self, low=0, high=None, **options):
        """Plots power vs frequency.

        low: int index to start at 
        high: int index to end at
        """
        thinkplot.plot(self.fs[low:high], self.power[low:high], **options)
开发者ID:NSasquatch,项目名称:vocoder,代码行数:7,代码来源:thinkdsp.py

示例8: plot_facebook

def plot_facebook():
    """Plot Facebook prices and a smoothed time series.
    """
    names = ['date', 'open', 'high', 'low', 'close', 'volume']
    df = pd.read_csv('fb.csv', header=0, names=names, parse_dates=[0])
    close = df.close.values[::-1]
    dates = df.date.values[::-1]
    days = (dates - dates[0]) / np.timedelta64(1,'D')

    M = 30
    window = np.ones(M)
    window /= sum(window)
    smoothed = np.convolve(close, window, mode='valid')
    smoothed_days = days[M//2: len(smoothed) + M//2]
    
    thinkplot.plot(days, close, color=GRAY, label='daily close')
    thinkplot.plot(smoothed_days, smoothed, label='30 day average')
    
    last = days[-1]
    thinkplot.config(xlabel='Time (days)', 
                     ylabel='Price ($)',
                     xlim=[-7, last+7],
                     legend=True,
                     loc='lower right')
    thinkplot.save(root='convolution1')
开发者ID:AllenDowney,项目名称:ThinkDSP,代码行数:25,代码来源:convolution.py

示例9: make_figures

def make_figures():

    wave1 = make_wave(0)
    wave2 = make_wave(offset=1)

    thinkplot.preplot(2)
    wave1.segment(duration=0.01).plot(label='wave1')
    wave2.segment(duration=0.01).plot(label='wave2')

    numpy.corrcoef(wave1.ys, wave2.ys)

    thinkplot.save(root='autocorr1',
                   xlabel='time (s)',
                   ylabel='amplitude')


    offsets = numpy.linspace(0, PI2, 101)

    corrs = []
    for offset in offsets:
        wave2 = make_wave(offset)
        corr = numpy.corrcoef(wave1.ys, wave2.ys)[0, 1]
        corrs.append(corr)
    
    thinkplot.plot(offsets, corrs)
    thinkplot.save(root='autocorr2',
                   xlabel='offset (radians)',
                   ylabel='correlation',
                   xlim=[0, PI2])
开发者ID:PMKeene,项目名称:ThinkDSP,代码行数:29,代码来源:autocorr.py

示例10: PlotResampledByAge

def PlotResampledByAge(resps, **options):
    samples = [thinkstats2.ResampleRowsWeighted(resp) for resp in resps]
    sample = pandas.concat(samples, ignore_index=True)
    groups = sample.groupby('decade')
    
    #number of group divisions
    n = 6
    #number of years per group if there are n groups
    group_size = 30/n 
    
    #labels age brackets depending on # divs
    labels = ['{} to {}'.format(int(15 + group_size * i), int(15+(i+1)*group_size)) for i in range(n)] 
    # 0 representing 15-24, 1 being 25-34, and 2 being 35-44
    
    #initilize dictionary of size n, with empty lists
    prob_dict = {i: [] for i in range(n)} 
    #TODO: Look into not hardcoding this
    decades = [30,40, 50, 60, 70, 80, 90]
    
    for _, group in groups:
        #calcualates the survival function for each decade
        _, sf = survival.EstimateSurvival(group)
        if len(sf.ts) > 1:
            #iterates through all n age groups to find the probability of marriage for that group
            for group_num in range(0,n):
                temp_prob_list = sf.Probs([t for t in sf.ts 
                                           if (15 + group_size*group_num) <= t <= (15 + (group_num+1)*group_size)])
                if len(temp_prob_list) != 0:
                    prob_dict[group_num].append(sum(temp_prob_list)/len(temp_prob_list))
                else:
                    pass
    for key in prob_dict:
        xs = decades[0:len(prob_dict[key])]
        thinkplot.plot(xs, prob_dict[key], label=labels[key], **options)
开发者ID:TheloniusJ,项目名称:MarriageNSFG,代码行数:34,代码来源:survival.py

示例11: plot

    def plot(self, label=''):
        """Plots the wave.

        label: string label for the plotted line
        """
        n = len(self.ys)
        ts = numpy.linspace(0, self.duration, n)
        thinkplot.plot(ts, self.ys, label=label)
开发者ID:cornercase,项目名称:ThinkDSP,代码行数:8,代码来源:thinkdsp.py

示例12: plot_pink_autocorr

def plot_pink_autocorr(beta, label):
    """Makes a plot showing autocorrelation for pink noise.

    beta: parameter of pink noise
    label: string label for the plot
    """
    signal = thinkdsp.PinkNoise(beta=beta)
    wave = signal.make_wave(duration=1.0, framerate=11025)
    lags, corrs = autocorr(wave)
    thinkplot.plot(lags, corrs, label=label)
开发者ID:jenwei,项目名称:accelerometer-interpreter,代码行数:10,代码来源:autocorr.py

示例13: plot

def plot(res, index):

    slices = [[0, None], [400, 1000], [860, 900]]
    start, end = slices[index]
    xs, ys = zip(*res[start:end])
    thinkplot.plot(xs, ys)
    thinkplot.save(root='dft%d' % index,
                   xlabel='freq (Hz)',
                   ylabel='cov',
                   formats=['png'])
开发者ID:cornercase,项目名称:ThinkDSP,代码行数:10,代码来源:example4.py

示例14: plot_power

    def plot_power(self, high=None, **options):
        """Plots power vs frequency.

        high: frequency to cut off at
        """
        if self.full:
            fs, amps = self.render_full(high)
            thinkplot.plot(fs, amps**2, **options)
        else:
            i = None if high is None else find_index(high, self.fs)
            thinkplot.plot(self.fs[:i], self.power[:i], **options)
开发者ID:DGITTer,项目名称:Faltungshall,代码行数:11,代码来源:thinkdsp.py

示例15: autocorr

def autocorr(wave):
    n = len(wave.ys)

    corrs = []
    lags = range(n//2)
    for lag in lags:
        y1 = wave.ys[lag:]
        y2 = wave.ys[:n-lag]
        corr = numpy.corrcoef(y1, y2)[0, 1]
        corrs.append(corr)

    thinkplot.plot(lags, corrs)
    thinkplot.show()
开发者ID:PMKeene,项目名称:ThinkDSP,代码行数:13,代码来源:autocorr.py


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