本文整理汇总了Python中thinkplot.plot函数的典型用法代码示例。如果您正苦于以下问题:Python plot函数的具体用法?Python plot怎么用?Python plot使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了plot函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: plot
def plot(self, high=None, **options):
"""Plots amplitude vs frequency.
Note: if this is a full spectrum, it ignores low and high
high: frequency to cut off at
"""
if self.full:
fs, amps = self.render_full(high)
thinkplot.plot(fs, amps, **options)
else:
i = None if high is None else find_index(high, self.fs)
thinkplot.plot(self.fs[:i], self.amps[:i], **options)
开发者ID:DGITTer,项目名称:Faltungshall,代码行数:13,代码来源:thinkdsp.py
示例17: 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
示例18: overlapping_windows
def overlapping_windows():
"""Makes a figure showing overlapping hamming windows.
"""
n = 256
window = numpy.hamming(n)
thinkplot.preplot(num=5)
start = 0
for i in range(5):
xs = numpy.arange(start, start + n)
thinkplot.plot(xs, window)
start += n / 2
thinkplot.save(root="windowing3", xlabel="time (s)", axis=[0, 800, 0, 1.05])
开发者ID:quakig,项目名称:ThinkDSP,代码行数:15,代码来源:example3.py
示例19: make_figures
def make_figures():
"""Makes figures showing complex signals.
"""
amps = numpy.array([0.6, 0.25, 0.1, 0.05])
freqs = [100, 200, 300, 400]
framerate = 11025
ts = numpy.linspace(0, 1, framerate)
ys = synthesize1(amps, freqs, ts)
print(ys)
thinkplot.preplot(2)
n = framerate / 25
thinkplot.plot(ts[:n], ys[:n].real, label='real')
thinkplot.plot(ts[:n], ys[:n].imag, label='imag')
thinkplot.save(root='dft1',
xlabel='time (s)',
ylabel='wave',
ylim=[-1.05, 1.05])
ys = synthesize2(amps, freqs, ts)
amps2 = amps * numpy.exp(1.5j)
ys2 = synthesize2(amps2, freqs, ts)
thinkplot.preplot(2)
thinkplot.plot(ts[:n], ys.real[:n], label=r'$\phi_0 = 0$')
thinkplot.plot(ts[:n], ys2.real[:n], label=r'$\phi_0 = 1.5$')
thinkplot.save(root='dft2',
xlabel='time (s)',
ylabel='wave',
ylim=[-1.05, 1.05],
loc='lower right')
framerate = 10000
signal = thinkdsp.SawtoothSignal(freq=500)
wave = signal.make_wave(duration=0.1, framerate=framerate)
hs = dft(wave.ys)
amps = numpy.absolute(hs)
N = len(hs)
fs = numpy.arange(N) * framerate / N
thinkplot.plot(fs, amps)
thinkplot.save(root='dft3',
xlabel='frequency (Hz)',
ylabel='amplitude',
legend=False)
开发者ID:Hydex,项目名称:ThinkDSP,代码行数:48,代码来源:dft.py
示例20: plot_diff_filters
def plot_diff_filters(wave):
window1 = np.array([1, -1])
window2 = np.array([-1, 4, -3]) / 2.0
window3 = np.array([2, -9, 18, -11]) / 6.0
window4 = np.array([-3, 16, -36, 48, -25]) / 12.0
window5 = np.array([12, -75, 200, -300, 300, -137]) / 60.0
thinkplot.preplot(5)
for i, window in enumerate([window1, window2, window3, window4, window5]):
padded = thinkdsp.zero_pad(window, len(wave))
fft_window = np.fft.rfft(padded)
n = len(fft_window)
thinkplot.plot(abs(fft_window)[:], label=i+1)
thinkplot.show()
开发者ID:EricAtTCC,项目名称:ThinkDSP,代码行数:16,代码来源:diff_int.py
注:本文中的thinkplot.plot函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论