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

Python thinkplot.config函数代码示例

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

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



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

示例1: plot_sincs

def plot_sincs():
    start = 1.0
    duration = 0.01
    factor = 4

    short = wave.segment(start=start, duration=duration)
    short.plot()

    sampled = sample(short, factor)
    sampled.plot_vlines(color='gray')


    spectrum = sampled.make_spectrum()
    boxcar = make_boxcar(spectrum, factor)
    sinc = boxcar.make_wave()
    sinc.shift(sampled.ts[0])
    sinc.roll(len(sinc)//2)

    thinkplot.preplot(1)
    sinc.plot()

    # CAUTION: don't call plot_sinc_demo with a large wave or it will
    # fill memory and crash
    plot_sinc_demo(short, 4)

    start = short.start + 0.004
    duration = 0.00061
    plot_sinc_demo(short, 4, start, duration)
    thinkplot.config(xlim=[start, start+duration],
                         ylim=[-0.05, 0.17], legend=False)
开发者ID:vpillajr,项目名称:ThinkDSP,代码行数:30,代码来源:sampling.py


示例2: aliasing_example

def aliasing_example(offset=0.000003):
    """Makes a figure showing the effect of aliasing.
    """
    framerate = 10000

    def plot_segment(freq):
        signal = thinkdsp.CosSignal(freq)
        duration = signal.period*4
        thinkplot.Hlines(0, 0, duration, color='gray')
        segment = signal.make_wave(duration, framerate=framerate*10)
        segment.plot(linewidth=0.5, color='gray')
        segment = signal.make_wave(duration, framerate=framerate)
        segment.plot_vlines(label=freq, linewidth=4)

    thinkplot.preplot(rows=2)
    plot_segment(4500)
    thinkplot.config(axis=[-0.00002, 0.0007, -1.05, 1.05])

    thinkplot.subplot(2)
    plot_segment(5500)
    thinkplot.config(axis=[-0.00002, 0.0007, -1.05, 1.05])

    thinkplot.save(root='aliasing1',
                   xlabel='Time (s)',
                   formats=FORMATS)
开发者ID:AllenDowney,项目名称:ThinkDSP,代码行数:25,代码来源:aliasing.py


示例3: 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


示例4: plot_convolution

def plot_convolution():
    response = thinkdsp.read_wave("180961__kleeb__gunshots.wav")
    response = response.segment(start=0.26, duration=5.0)
    response.normalize()

    dt = 1
    shift = dt * response.framerate
    factor = 0.5

    gun2 = response + shifted_scaled(response, shift, factor)
    gun2.plot()
    thinkplot.config(xlabel="time (s)", ylabel="amplitude", ylim=[-1.05, 1.05], legend=False)
    thinkplot.save(root="systems8")

    signal = thinkdsp.SawtoothSignal(freq=410)
    wave = signal.make_wave(duration=0.1, framerate=response.framerate)

    total = 0
    for j, y in enumerate(wave.ys):
        total += shifted_scaled(response, j, y)

    total.normalize()

    wave.make_spectrum().plot(high=500, color="0.7", label="original")
    segment = total.segment(duration=0.2)
    segment.make_spectrum().plot(high=1000, label="convolved")
    thinkplot.config(xlabel="frequency (Hz)", ylabel="amplitude")
    thinkplot.save(root="systems9")
开发者ID:younlonglin,项目名称:ThinkDSP,代码行数:28,代码来源:systems.py


示例5: 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


示例6: plot_ratios

def plot_ratios(in_wave, out_wave):

    # compare filters for cumsum and integration
    diff_window = np.array([1.0, -1.0])
    padded = thinkdsp.zero_pad(diff_window, len(in_wave))
    diff_wave = thinkdsp.Wave(padded, framerate=in_wave.framerate)
    diff_filter = diff_wave.make_spectrum()
    
    cumsum_filter = diff_filter.copy()
    cumsum_filter.hs = 1 / cumsum_filter.hs
    cumsum_filter.plot(label='cumsum filter', color=GRAY, linewidth=7)
    
    integ_filter = cumsum_filter.copy()
    integ_filter.hs = integ_filter.framerate / (PI2 * 1j * integ_filter.fs)
    integ_filter.plot(label='integral filter')

    thinkplot.config(xlim=[0, integ_filter.max_freq],
                     yscale='log', legend=True)
    thinkplot.save('diff_int8')

    # compare cumsum filter to actual ratios
    cumsum_filter.plot(label='cumsum filter', color=GRAY, linewidth=7)
    
    in_spectrum = in_wave.make_spectrum()
    out_spectrum = out_wave.make_spectrum()
    ratio_spectrum = out_spectrum.ratio(in_spectrum, thresh=1)
    ratio_spectrum.plot(label='ratio', style='.', markersize=4)

    thinkplot.config(xlabel='Frequency (Hz)',
                     ylabel='Amplitude ratio',
                     xlim=[0, integ_filter.max_freq],
                     yscale='log', legend=True)
    thinkplot.save('diff_int9')
开发者ID:EricAtTCC,项目名称:ThinkDSP,代码行数:33,代码来源:diff_int.py


示例7: plot_filters

def plot_filters(close):
    """Plots the filter that corresponds to diff, deriv, and integral.
    """
    thinkplot.preplot(3, cols=2)

    diff_window = np.array([1.0, -1.0])
    diff_filter = make_filter(diff_window, close)
    diff_filter.plot(label='diff')

    deriv_filter = close.make_spectrum()
    deriv_filter.hs = PI2 * 1j * deriv_filter.fs
    deriv_filter.plot(label='derivative')

    thinkplot.config(xlabel='Frequency (1/day)',
                     ylabel='Amplitude ratio',
                     loc='upper left')

    thinkplot.subplot(2)
    integ_filter = deriv_filter.copy()
    integ_filter.hs = 1 / (PI2 * 1j * integ_filter.fs)

    integ_filter.plot(label='integral')
    thinkplot.config(xlabel='Frequency (1/day)',
                     ylabel='Amplitude ratio', 
                     yscale='log')
    thinkplot.save('diff_int3')
开发者ID:EricAtTCC,项目名称:ThinkDSP,代码行数:26,代码来源:diff_int.py


示例8: triangle_example

def triangle_example(freq):
    """Makes a figure showing a triangle wave.

    freq: frequency in Hz
    """
    framerate = 10000
    signal = thinkdsp.TriangleSignal(freq)

    duration = signal.period*3
    segment = signal.make_wave(duration, framerate=framerate)
    segment.plot()
    thinkplot.save(root='triangle-%d-1' % freq,
                   xlabel='Time (s)',
                   axis=[0, duration, -1.05, 1.05])

    wave = signal.make_wave(duration=0.5, framerate=framerate)
    spectrum = wave.make_spectrum()

    thinkplot.preplot(cols=2)
    spectrum.plot()
    thinkplot.config(xlabel='Frequency (Hz)',
                     ylabel='Amplitude')

    thinkplot.subplot(2)
    spectrum.plot()
    thinkplot.config(ylim=[0, 500],
                     xlabel='Frequency (Hz)')
    
    thinkplot.save(root='triangle-%d-2' % freq)
开发者ID:AllenDowney,项目名称:ThinkDSP,代码行数:29,代码来源:aliasing.py


示例9: main

def main():
    
    # make_figures()

    wave = thinkdsp.read_wave('28042__bcjordan__voicedownbew.wav')
    wave.unbias()
    wave.normalize()
    track_pitch(wave)

    
    return


    thinkplot.preplot(rows=1, cols=2)
    plot_shifted(wave, 0.0003)
    thinkplot.config(xlabel='time (s)',
                     ylabel='amplitude',
                     ylim=[-1, 1])

    thinkplot.subplot(2)
    plot_shifted(wave, 0.00225)
    thinkplot.config(xlabel='time (s)',
                     ylim=[-1, 1])

    thinkplot.save(root='autocorr3')
开发者ID:PMKeene,项目名称:ThinkDSP,代码行数:25,代码来源:autocorr.py


示例10: dct_plot

def dct_plot():
    signal = thinkdsp.TriangleSignal(freq=400)
    wave = signal.make_wave(duration=1.0, framerate=10000)
    dct = wave.make_dct()
    dct.plot()
    thinkplot.config(xlabel='Frequency (Hz)', ylabel='DCT')
    thinkplot.save(root='dct1',
                   formats=['pdf', 'eps'])
开发者ID:AllenDowney,项目名称:ThinkDSP,代码行数:8,代码来源:dct.py


示例11: plot_diff_filter

def plot_diff_filter(close):
    """Plots the filter that corresponds to first order finite difference.
    """
    diff_window = np.array([1.0, -1.0])
    diff_filter = make_filter(diff_window, close)
    diff_filter.plot()
    thinkplot.config(xlabel='Frequency (1/day)', ylabel='Amplitude ratio')
    thinkplot.save('diff_int3')
开发者ID:vkalantzis,项目名称:ThinkDSP,代码行数:8,代码来源:diff_int.py


示例12: plot_convolution

def plot_convolution(response):
    """Plots the impulse response and a shifted, scaled copy.
    """
    shift = 1
    factor = 0.5
    
    gun2 = response + shifted_scaled(response, shift, factor)
    gun2.plot()
    thinkplot.config(xlabel='Time (s)',
                     ylim=[-1.05, 1.05],
                     legend=False)
    thinkplot.save(root='systems8')
开发者ID:AllenDowney,项目名称:ThinkDSP,代码行数:12,代码来源:systems.py


示例13: process_noise

def process_noise(signal, root='white'):
    """Plots wave and spectrum for noise signals.

    signal: Signal
    root: string used to generate file names
    """
    framerate = 11025
    wave = signal.make_wave(duration=0.5, framerate=framerate)

    # 0: waveform
    segment = wave.segment(duration=0.1)
    segment.plot(linewidth=1, alpha=0.5)
    thinkplot.save(root=root+'noise0',
                   xlabel='Time (s)',
                   ylim=[-1.05, 1.05])

    spectrum = wave.make_spectrum()

    # 1: spectrum
    spectrum.plot_power(linewidth=1, alpha=0.5)
    thinkplot.save(root=root+'noise1',
                   xlabel='Frequency (Hz)',
                   ylabel='Power',
                   xlim=[0, spectrum.fs[-1]])

    slope, _, _, _, _ = spectrum.estimate_slope()
    print('estimated slope', slope)

    # 2: integrated spectrum
    integ = spectrum.make_integrated_spectrum()
    integ.plot_power()
    thinkplot.save(root=root+'noise2',
                   xlabel='Frequency (Hz)',
                   ylabel='Cumulative fraction of total power',
                   xlim=[0, framerate/2])

    # 3: log-log power spectrum
    spectrum.hs[0] = 0
    thinkplot.preplot(cols=2)
    spectrum.plot_power(linewidth=1, alpha=0.5)
    thinkplot.config(xlabel='Frequency (Hz)',
                     ylabel='Power',
                     xlim=[0, framerate/2])

    thinkplot.subplot(2)
    spectrum.plot_power(linewidth=1, alpha=0.5)
    thinkplot.config(xlabel='Frequency (Hz)',                  
                   xscale='log',
                   yscale='log',
                   xlim=[0, framerate/2])

    thinkplot.save(root=root+'noise3')
开发者ID:AllenDowney,项目名称:ThinkDSP,代码行数:52,代码来源:noise.py


示例14: plot_diff_deriv

def plot_diff_deriv(close):
    change = thinkdsp.Wave(np.diff(close.ys), framerate=1)

    deriv_spectrum = close.make_spectrum().differentiate()
    deriv = deriv_spectrum.make_wave()

    low, high = 0, 50
    thinkplot.preplot(2)
    thinkplot.plot(change.ys[low:high], label='diff')
    thinkplot.plot(deriv.ys[low:high], label='derivative')

    thinkplot.config(xlabel='Time (day)', ylabel='Price change ($)')
    thinkplot.save('diff_int4')
开发者ID:AllenDowney,项目名称:ThinkDSP,代码行数:13,代码来源:diff_int.py


示例15: plot_sampling

def plot_sampling(wave, root):
    ax1 = thinkplot.preplot(2, rows=2)
    wave.make_spectrum(full=True).plot(label='spectrum')

    thinkplot.config(xlim=XLIM, xticklabels='invisible')

    ax2 = thinkplot.subplot(2)
    sampled = sample(wave, 4)
    sampled.make_spectrum(full=True).plot(label='sampled')
    thinkplot.config(xlim=XLIM, xlabel='Frequency (Hz)')

    thinkplot.save(root=root,
                   formats=FORMATS)
开发者ID:EricAtTCC,项目名称:ThinkDSP,代码行数:13,代码来源:sampling.py


示例16: plot_amen2

def plot_amen2():
    wave = thinkdsp.read_wave('263868__kevcio__amen-break-a-160-bpm.wav')
    wave.normalize()

    ax1 = thinkplot.preplot(6, rows=4)
    wave.make_spectrum(full=True).plot(label='spectrum')
    xlim = [-22050-250, 22050]
    thinkplot.config(xlim=xlim, xticklabels='invisible')

    ax2 = thinkplot.subplot(2)
    impulses = make_impulses(wave, 4)
    impulses.make_spectrum(full=True).plot(label='impulses')
    thinkplot.config(xlim=xlim, xticklabels='invisible')

    ax3 = thinkplot.subplot(3)
    sampled = wave * impulses
    spectrum = sampled.make_spectrum(full=True)
    spectrum.plot(label='sampled')
    thinkplot.config(xlim=xlim, xticklabels='invisible')

    ax4 = thinkplot.subplot(4)
    spectrum.low_pass(5512.5)
    spectrum.plot(label='filtered')
    thinkplot.config(xlim=xlim, xlabel='Frequency (Hz)')

    thinkplot.save(root='sampling4',
                   formats=FORMATS)
开发者ID:vpillajr,项目名称:ThinkDSP,代码行数:27,代码来源:sampling.py


示例17: plot_wave_and_spectrum

def plot_wave_and_spectrum(wave, root):
    """Makes a plot showing 
    """
    thinkplot.preplot(cols=2)
    wave.plot()
    thinkplot.config(xlabel="days", xlim=[0, 1650], ylabel="dollars", legend=False)

    thinkplot.subplot(2)
    spectrum = wave.make_spectrum()
    print(spectrum.estimate_slope())
    spectrum.plot()
    thinkplot.config(xlabel="frequency (1/days)", ylabel="power", xscale="log", yscale="log", legend=False)

    thinkplot.save(root=root)
开发者ID:younlonglin,项目名称:ThinkDSP,代码行数:14,代码来源:systems.py


示例18: plot_sawtooth_and_spectrum

def plot_sawtooth_and_spectrum(wave, root):
    """Makes a plot showing a sawtoothwave and its spectrum.
    """
    thinkplot.preplot(cols=2)
    wave.plot()
    thinkplot.config(xlabel='Time (s)')

    thinkplot.subplot(2)
    spectrum = wave.make_spectrum()
    spectrum.plot()
    thinkplot.config(xlabel='Frequency (Hz)',
                     ylabel='Amplitude',
                     xlim=[0, spectrum.fs[-1]])

    thinkplot.save(root)
开发者ID:EricAtTCC,项目名称:ThinkDSP,代码行数:15,代码来源:diff_int.py


示例19: plot_autocorr

def plot_autocorr():
    """Plots autocorrelation for pink noise with different parameters
    """
    numpy.random.seed(19)
    thinkplot.preplot(3)

    for beta in [1.2, 1.0, 0.7]:
        label = r'$\beta$ = %.1f' % beta
        plot_pink_autocorr(beta, label)

    thinkplot.config(xlabel='lag', 
                     ylabel='correlation', 
                     xlim=[-1, 200], 
                     ylim=[-0.05, 1.05])
    thinkplot.save(root='autocorr4')
开发者ID:jenwei,项目名称:accelerometer-interpreter,代码行数:15,代码来源:autocorr.py


示例20: plot_filter

def plot_filter():
    """Plots the filter that corresponds to a 2-element moving average.
    """
    impulse = np.zeros(8)
    impulse[0] = 1
    wave = thinkdsp.Wave(impulse, framerate=8)
    
    impulse_spectrum = wave.make_spectrum(full=True)
    window_array = np.array([0.5, 0.5, 0, 0, 0, 0, 0, 0,])
    window = thinkdsp.Wave(window_array, framerate=8)
    filtr = window.make_spectrum(full=True)

    filtr.plot()
    thinkplot.config(xlabel='Frequency', ylabel='Amplitude')
    thinkplot.save('systems1')
开发者ID:AllenDowney,项目名称:ThinkDSP,代码行数:15,代码来源:systems.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python thinkplot.plot函数代码示例发布时间:2022-05-27
下一篇:
Python thinkdsp.read_wave函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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