Limiting the Axis Range of a Subplot
As you've encountered, setting the y-axis range of a subplot is not straightforward. Here's a solution and some additional considerations.
The ylim() Method
To restrict the y-axis range of the second subplot to [0,1000], use the ylim() method after generating the plot:
<code class="python">pylab.plot(abs(fft)) # Plot the data pylab.ylim([0, 1000]) # Set the y-axis range</code>
Note: Ensure that the ylim() command is executed after the plot command.
Other Improvements
pylab.xlabel("Frequency") pylab.ylabel("[abs(FFT)]")
pylab.legend(["Signal"])
以上是如何使用 ylim() 控制子圖的 Y 軸範圍?的詳細內容。更多資訊請關注PHP中文網其他相關文章!