最令人沮丧的事情之一是,当您按照书上的教程进行操作时,它无法正常工作。我不知道为什么这不起作用。 我现在使用IPython来制作我的情节。我有这样的代码:Python在剧情中没有正确设置范围
from __future__ import division
fig,ax =subplots()
f=1.0# Hz, signal frequency
fs = 5.0 # Hz, sampling rate (ie. >= 2*f)
t= arange(-1,1+1/fs,1/fs) # sample interval, symmetric
# for convenience later
x= sin(2*pi*f*t)
ax.plot(t,x,'o-')
ax.set_xlabel('Time' ,fontsize=18)
ax.set_ylabel(' Amplitude' ,fontsize=18)
这样做具有以下图表:
预计书中的图表。但后来当我添加此额外的代码:
fig,ax = subplots()
ax.plot(t,x,'o-')
ax.plot(xmin = 1/(4*f)-1/fs*3,
xmax = 1/(4*f)+1/fs*3,
ymin = 0,
ymax = 1.1)
ax.set_xlabel('Time',fontsize =18)
ax.set_ylabel('Amplitude',fontsize = 18)
我也得到在同一张图,即使我设置了图形范围。 我试着按参数做参数,因为我发现在另一个问题 - ax.ymin = 0,ax.ymax = 1.1等....
为什么会发生这种情况,我该怎么做查看“放大”图?
从哪个教程复制了第二段代码? A会说ax.plot()没有xmin,xmax等参数。 – joaquin
来自“python for signal processing”一书,采样定理部分。链接:http://python-for-signal-processing.blogspot.com/2012/09/investigating-sampling-theorem-in-this.html 书中的代码与网站中的代码有点不同,但他们都没有工作。 – triplebig
我认为你错误地复制了该链接中的代码。它说'axis(xmin =,....)'不是'plot(xmin =,...)'。 Probalby你不应该责怪该教程,但别人... – joaquin