最令人沮喪的事情之一是,當您按照書上的教程進行操作時,它無法正常工作。我不知道爲什麼這不起作用。 我現在使用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