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


Python thinkplot.save函数代码示例

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


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

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

示例2: plot_response

def plot_response():
    thinkplot.preplot(cols=2)

    response = thinkdsp.read_wave("180961__kleeb__gunshots.wav")
    response = response.segment(start=0.26, duration=5.0)
    response.normalize()
    response.plot()
    thinkplot.config(xlabel="time", xlim=[0, 5.0], ylabel="amplitude", ylim=[-1.05, 1.05])

    thinkplot.subplot(2)
    transfer = response.make_spectrum()
    transfer.plot()
    thinkplot.config(xlabel="frequency", xlim=[0, 22500], ylabel="amplitude")

    thinkplot.save(root="systems6")

    wave = thinkdsp.read_wave("92002__jcveliz__violin-origional.wav")
    wave.ys = wave.ys[: len(response)]
    wave.normalize()
    spectrum = wave.make_spectrum()

    output = (spectrum * transfer).make_wave()
    output.normalize()

    wave.plot(color="0.7")
    output.plot(alpha=0.4)
    thinkplot.config(xlabel="time", xlim=[0, 5.0], ylabel="amplitude", ylim=[-1.05, 1.05])
    thinkplot.save(root="systems7")
开发者ID:younlonglin,项目名称:ThinkDSP,代码行数:28,代码来源:systems.py

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

示例4: chirp_spectrum

def chirp_spectrum():
    """Plots the spectrum of a one-second one-octave linear chirp.
    """
    signal = thinkdsp.Chirp(start=220, end=440)
    wave = signal.make_wave(duration=1)

    thinkplot.preplot(3, cols=3)
    duration = 0.01
    wave.segment(0, duration).plot()
    thinkplot.config(ylim=[-1.05, 1.05])

    thinkplot.subplot(2)
    wave.segment(0.5, duration).plot()
    thinkplot.config(yticklabels='invisible',
                     xlabel='Time (s)')

    thinkplot.subplot(3)
    wave.segment(0.9, duration).plot()
    thinkplot.config(yticklabels='invisible')

    thinkplot.save('chirp3')


    spectrum = wave.make_spectrum()
    spectrum.plot(high=700)
    thinkplot.save('chirp1',
                   xlabel='Frequency (Hz)',
                   ylabel='Amplitude')
开发者ID:EricAtTCC,项目名称:ThinkDSP,代码行数:28,代码来源:chirp.py

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

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

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

示例8: aliasing_example

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

    freq1 = 4500
    signal = thinkdsp.CosSignal(freq1)
    duration = signal.period*5
    segment = signal.make_wave(duration, framerate=framerate)
    thinkplot.Hlines(0, 0, duration, color='gray')

    segment.shift(-offset)
    segment.plot_vlines(label=freq1, linewidth=3)

    freq2 = 5500
    signal = thinkdsp.CosSignal(freq2)
    segment = signal.make_wave(duration, framerate=framerate)
    segment.shift(+offset)
    segment.plot_vlines(label=freq2, linewidth=3)

    thinkplot.save(root='aliasing1',
                   xlabel='Time (s)',
                   axis=[-0.00002, duration, -1.05, 1.05]
                   )
开发者ID:EricAtTCC,项目名称:ThinkDSP,代码行数:25,代码来源:aliasing.py

示例9: plot_pink_noise

def plot_pink_noise():
    """Makes a plot showing power spectrums for pink noise.
    """
    thinkdsp.random_seed(20)

    duration = 1.0
    framerate = 512

    signal = thinkdsp.UncorrelatedUniformNoise()
    wave = signal.make_wave(duration=duration, framerate=framerate)
    white = wave.make_spectrum()

    signal = thinkdsp.PinkNoise()
    wave = signal.make_wave(duration=duration, framerate=framerate)
    pink = wave.make_spectrum()

    signal = thinkdsp.BrownianNoise()
    wave = signal.make_wave(duration=duration, framerate=framerate)
    red = wave.make_spectrum()

    linewidth = 1
    white.plot_power(low=1, label='white', color='gray', linewidth=linewidth)
    pink.plot_power(low=1, label='pink', color='pink', linewidth=linewidth)
    red.plot_power(low=1, label='red', color='red', linewidth=linewidth)
    thinkplot.save(root='noise-triple',
                   xlabel='frequency (Hz)',
                   ylabel='power',
                   xscale='log',
                   yscale='log',
                   axis=[1, 300, 1e-4, 1e5])
开发者ID:Hydex,项目名称:ThinkDSP,代码行数:30,代码来源:noise.py

示例10: plot_pink_noise

def plot_pink_noise():
    """Makes a plot showing power spectrums for pink noise.
    """
    thinkdsp.random_seed(20)

    duration = 1.0
    framerate = 512

    def make_spectrum(signal):
        wave = signal.make_wave(duration=duration, framerate=framerate)
        spectrum = wave.make_spectrum()
        spectrum.hs[0] = 0
        return spectrum

    signal = thinkdsp.UncorrelatedUniformNoise()
    white = make_spectrum(signal)

    signal = thinkdsp.PinkNoise()
    pink = make_spectrum(signal)

    signal = thinkdsp.BrownianNoise()
    red = make_spectrum(signal)

    linewidth = 2
    white.plot_power(label='white', color='#9ecae1', linewidth=linewidth)
    pink.plot_power(label='pink', color='#4292c6', linewidth=linewidth)
    red.plot_power(label='red', color='#2171b5', linewidth=linewidth)
    thinkplot.save(root='noise-triple',
                   xlabel='Frequency (Hz)',
                   ylabel='Power',
                   xscale='log',
                   yscale='log',
                   xlim=[1, red.fs[-1]])
开发者ID:EricAtTCC,项目名称:ThinkDSP,代码行数:33,代码来源:noise.py

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

示例12: plot_beeps

def plot_beeps():
    wave = thinkdsp.read_wave('253887__themusicalnomad__positive-beeps.wav')
    wave.normalize()

    thinkplot.preplot(3)

    # top left
    ax1 = plt.subplot2grid((4, 2), (0, 0), rowspan=2)
    plt.setp(ax1.get_xticklabels(), visible=False)

    wave.plot()
    thinkplot.config(title='Input waves', legend=False)

    # bottom left
    imp_sig = thinkdsp.Impulses([0.01, 0.4, 0.8, 1.2], 
                                amps=[1, 0.5, 0.25, 0.1])
    impulses = imp_sig.make_wave(start=0, duration=1.3, 
                                 framerate=wave.framerate)

    ax2 = plt.subplot2grid((4, 2), (2, 0), rowspan=2, sharex=ax1)
    impulses.plot()
    thinkplot.config(xlabel='Time (s)')

    # center right
    convolved = wave.convolve(impulses)

    ax3 = plt.subplot2grid((4, 2), (1, 1), rowspan=2)
    plt.title('Convolution')
    convolved.plot()
    thinkplot.config(xlabel='Time (s)')

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

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

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

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


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