# 本益比河流圖教學｜用 Python Plotly 打造客製化看盤工具

台股研究 2021年9月27日 約 2 分鐘閱讀

用 Plotly 的 Filled Area Plot 將台積電本益比上下限切八層，搭配 FinLab API 取出收盤價與 PE/PB，再封裝成 plot\_tw\_stock\_river 函數，mode 一鍵切換本益比與股價淨值比河流圖。

學會用 Plotly 的 Filled Area Plot，把本益比上下限分層繪製成河流圖，封裝成函數一鍵切換 PE / PB 河流圖。

## 本益比河流圖的用途

取標的一段時間內的本益比上下限，再決定要分割幾層，用來判斷獲利或成長性穩定的股票所處於的本益比區間。

高成長股或獲利不夠穩定的企業不適用，本益比河流圖趨勢變化會太過劇烈。

本益比河流圖上升或層距擴大代表獲利逐漸成長，買在河流圖中下緣是理想位置。

本益比河流圖下降或層距縮小代表獲利逐步下掉，若股價位於河流圖上緣則風險偏高。

[![適合使用本益比的穩定企業，本益比河流圖呈現平穩上升趨勢](https://r2.finlab.finance/blog/pepb-river-chart/newplot-10-1024x264.png)](https://r2.finlab.finance/blog/pepb-river-chart/newplot-10-1024x264.png)

依本文重跑

## 執行這個策略

複製提示詞，讓 AI 依照上方證據的資料、條件與風險檢查重跑一次。

告訴你的AI：

幫我設定 FinLab，重現這篇文章，請讀：https\://finlab.finance/setup?relatedUrl=/blog/pe-river-chart-python-plotly

[免安裝，開啟 FinLab Studio](https://studio.finlab.finance/chat?lang=zh\&research_context=%7B%22v%22%3A1%2C%22source_url%22%3A%22https%3A%2F%2Ffinlab.finance%2Fblog%2Fpe-river-chart-python-plotly%22%7D)

[![不適合使用本益比的不穩定企業，本益比河流圖趨勢變化劇烈](https://r2.finlab.finance/blog/pepb-river-chart/newplot-11-1024x264.png)](https://r2.finlab.finance/blog/pepb-river-chart/newplot-11-1024x264.png)

VIP 區域接著會示範本益比河流圖 Plotly 實作，拆解不穩定企業的估值區間變化，並附可重現的 Python 圖表程式。

VIP 區域包含策略細節

登入後可看策略優化、完整程式碼與互動式回測報告

![韓承佑](https://finlab.finance/people/cheng-yu-han-avatar.jpg)

韓承佑

創辦人 & 量化研究員

韓承佑是 FinLab 創辦人，也是開源 Python 量化套件 finlab 的作者，長年投入台股與美股的量化策略研究、回測與教學。

[在 GitHub 上追蹤 →](https://github.com/koreal6803) [在 LinkedIn 上連結 →](https://www.linkedin.com/in/cheng-yu-han/)

FinLab AI

### 想建立自己的策略？

用自然語言描述你的選股想法，AI 自動驗證、回測、給你答案

[免費開始](https://finlab.finance/#get-started)

## 更多價值與基本面研究

[查看全部](https://finlab.finance/blog/category/value)

* [![現金股利調高選股：加進月營收動能，7 年年化 59.9%、夏普 1.83](https://r2.finlab.finance/blog/cash-dividend-increase-stock-selection/chart_equity.png) 現金股利調高選股：加進月營收動能，7 年年化 59.9%、夏普 1.83 年化報酬 59.9% · 台股](https://finlab.finance/blog/cash-dividend-increase-stock-selection)
* [![營收創新高選股：月營收動能優先買營收創 12 個月新高，年化 52.4%、夏普 1.62](https://r2.finlab.finance/blog/revenue-new-high-stock-selection/chart_equity.png) 營收創新高選股：月營收動能優先買營收創 12 個月新高，年化 52.4%、夏普 1.62 年化報酬 52.4% · 台股](https://finlab.finance/blog/revenue-new-high-stock-selection)
* [![月營收動能選股：台股 11 年回測年化 50%，夏普 1.46（附程式碼）](https://r2.finlab.finance/blog/monthly-revenue-momentum/chart_summary.png) 月營收動能選股：台股 11 年回測年化 50%，夏普 1.46（附程式碼） 年化報酬 50.0% · 台股](https://finlab.finance/blog/monthly-revenue-momentum)
* [![財報選股 3 指標回測：2020 年起年化 45.6%，近三年輸 0050](https://r2.finlab.finance/blog/fundamental-3-indicators/image-4-1024x938.png) 財報選股 3 指標回測：2020 年起年化 45.6%，近三年輸 0050 年化報酬 45.6% · 台股](https://finlab.finance/blog/fundamental-3-indicators)

投資警語：本文僅供教學參考，不構成投資建議。過去績效不代表未來表現，投資有風險。

來源：https://finlab.finance/blog/pe-river-chart-python-plotly｜資料日期：依上文各表格與段落標示｜頁面更新：2026-11-25
