Docs
Open Studio

Guides

Data visualization

On this page5

finlab.plot provides a suite of charting tools to help you gain deeper insight into market data. Every function returns a plotly figure; see the finlab.plot reference for all parameters.

To seeUseMarket
Candles and technical indicatorsplot_candles()Any price series
Financial metric rankings of holdingsplot_tw_stock_radar()US and Taiwan
Strategy returns against a benchmarkStrategyReturnStatsUS and Taiwan
Treemaps, river charts, multi-strategy holdingsplot_tw_stock_treemap(), plot_tw_stock_river(), StrategySunburstTaiwan only

Draw candles with technical indicators

plot_candles() draws a candlestick chart from any price series, with multiple EMA lines overlaid and technical indicator subplots such as STOCH and RSI below:

from finlab import data
from finlab.data import indicator
from finlab.plot import plot_candles

data.set_market('us')
symbol = 'AAPL'

overlay_func = {
    'ema_5': indicator('EMA', timeperiod=5),
    'ema_10': indicator('EMA', timeperiod=10),
    'ema_20': indicator('EMA', timeperiod=20),
    'ema_60': indicator('EMA', timeperiod=60),
}

k, d = indicator('STOCH')
rsi = indicator('RSI')
technical_func = [{'K': k, 'D': d}, {'RSI': rsi}]

plot_candles(
    symbol,
    close=data.get('price:close')[symbol],
    open_=data.get('price:open')[symbol],
    high=data.get('price:high')[symbol],
    low=data.get('price:low')[symbol],
    volume=data.get('price:volume')[symbol],
    recent_days=1000,
    resample='D',
    overlay_func=overlay_func,
    technical_func=technical_func,
)

data.indicator() uses unadjusted prices by default, so the candles above use the unadjusted price:* series too.

Compare holdings on financial metrics

The radar chart compares the indicator rankings of a portfolio's holdings. Each metric is ranked across all stocks and cut into levels, so metrics with different units are comparable. It supports the bar_polar, line_polar and scatter_polar modes.

bar_polar mode

from finlab import data
from finlab.plot import plot_tw_stock_radar

data.set_market('us')

feats = [
    'us_ratios:gross_profit_margin',
    'us_ratios:operating_profit_margin',
    'us_ratios:net_profit_margin',
    'us_key_metrics:return_on_equity',
]

plot_tw_stock_radar(
    portfolio=['AAPL', 'MSFT', 'NVDA', 'AMZN'], feats=feats, mode='bar_polar'
)

line_polar mode: your own financial metrics

Pick the metrics to compare with feats, and set the number of levels with cut_bins:

from finlab import data
from finlab.plot import plot_tw_stock_radar

data.set_market('us')

feats = [
    'us_ratios:gross_profit_margin',
    'us_ratios:operating_profit_margin',
    'us_ratios:net_profit_margin',
    'us_ratios:current_ratio',
    'us_ratios:debt_to_assets_ratio',
]

plot_tw_stock_radar(portfolio=['NVDA'], feats=feats, mode='line_polar', cut_bins=8)

us_ratios:* and us_key_metrics:* hold recent daily snapshots, which suits a latest-value comparison like this one.

Compare strategy returns with the S&P 500

StrategyReturnStats compares the returns of your uploaded strategies with the S&P 500 over a period:

from finlab import data
from finlab.plot import StrategyReturnStats

sp500 = data.get('world_index:adj_close')['^GSPC']

stats = StrategyReturnStats('2025-01-01', '2025-12-31', benchmark_return=sp500)
stats.plot_strategy_last_return().show()
stats.plot_strategy_creturn().show()

Taiwan-only charts

These helpers read Taiwan datasets and are for the Taiwan market only:

  • plot_tw_stock_candles(): candlestick chart that loads a Taiwan stock's prices for you.
  • plot_tw_stock_treemap(): nested treemap of Taiwan stocks grouped by market and industry, sized by market value or trading value and colored by return or another dataset.
  • plot_tw_stock_river(): P/E or P/B river chart that shows where a Taiwan stock's valuation sits within its historical range.
  • StrategySunburst: draws the holdings of your FinLab cloud strategies as a sunburst grouped by Taiwan industry. It is for Taiwan strategies only; see finlab.plot.
Treemap example (Taiwan market)
from finlab.plot import plot_tw_stock_treemap

# Taiwan market: block area is trading value, color is the return over the period
plot_tw_stock_treemap(
    start='2024-01-02', end='2024-01-31', area_ind='turnover', item='return_ratio'
)

Next steps

↑↓ Move Enter Open Esc Close