qis.plot_scatter_regression¶
- qis.plot_scatter_regression(prices, regime_benchmark, regime_classifier=None, drop_benchmark=True, is_add_alpha=True, x_var_format='{:.0%}', y_var_format='{:.0%}', beta_format='{:.2f}', xlabel=None, ylabel=None, title=None, display_estimated_betas=True, is_print_summary=False, add_last_date=False, framealpha=0.9, ax=None, **kwargs)[source]¶
Plot scatter regression with regime-conditional betas.
Creates a scatter plot showing asset returns vs benchmark returns, with fitted regression lines that have different slopes (betas) for each market regime. Background colors indicate regime boundaries.
- Parameters:
prices (DataFrame) – DataFrame of asset prices with benchmark included
regime_benchmark (str) – Column name of benchmark asset for regime classification
regime_classifier (RegimeClassifier | None) – Regime classifier instance. Uses
BenchmarkReturnsQuantilesRegimeby default.drop_benchmark (bool) – If True, exclude benchmark from regression outputs
is_add_alpha (bool) – If True, include regression intercepts.
x_var_format (str) – Format string for x-axis values (benchmark returns)
y_var_format (str) – Format string for y-axis values (asset returns)
beta_format (str) – Format string for displaying beta values in legend
xlabel (str | None) – Custom x-axis label (default: “x={benchmark}”)
ylabel (str | None) – Custom y-axis label (default: “Assets” or specific asset name)
title (str | None) – Plot title (default: None)
display_estimated_betas (bool) – If True, show detailed regime betas in legend
is_print_summary (bool) – If True, print OLS regression summaries
framealpha (float) – Legend frame transparency (0=transparent, 1=opaque)
add_last_date (bool) – If True, add annotation for most recent data point
ax (Axes | None) – Matplotlib axis to plot on (creates new figure if None)
**kwargs – Additional arguments passed to plotting utilities
- Returns:
Figure object if new figure created, None if plotting on existing axis
- Return type:
Figure | None