如何使用 ylim() 控制子圖的 Y 軸範圍?

DDD
發布: 2024-10-18 11:46:03
原創
404 人瀏覽過

How to Control the Y-Axis Range of a Subplot Using ylim()?

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

  • Axis Labels: Add labels to the axes for clarity:
pylab.xlabel("Frequency")
pylab.ylabel("[abs(FFT)]")
登入後複製
  • Legend: Include a legend to differentiate the plot lines:
pylab.legend(["Signal"])
登入後複製

以上是如何使用 ylim() 控制子圖的 Y 軸範圍?的詳細內容。更多資訊請關注PHP中文網其他相關文章!

來源:php
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!