Visualization¶
See the Visualization guide.
Plots¶
plots
¶
Dark-themed, publication-quality plots for jaxfolio.
Every function returns a matplotlib Figure so callers can further customize
or save. The functions cover the portfolio workflow (weights, efficient frontier,
equity curves, drawdowns, risk contributions, correlation network, HRP
dendrogram) and the options workflow (payoff diagrams, Greeks profiles, vol
surface). Colors are drawn from the validated dark palette in :mod:.theme.
plot_weights
¶
Horizontal bar chart of portfolio weights (largest holdings on top).
Source code in src/jaxfolio/viz/plots.py
plot_efficient_frontier
¶
plot_efficient_frontier(
returns: DataFrame,
*,
n_portfolios: int = 4000,
highlight: dict[str, object] | None = None,
seed: int = 0,
) -> Figure
Monte-Carlo efficient frontier colored by Sharpe ratio.
Simulates random long-only portfolios and plots them in risk/return space,
colored by Sharpe. Optionally overlays named :class:PortfolioResult markers
passed via highlight ({label: result}).
Source code in src/jaxfolio/viz/plots.py
plot_equity_curves
¶
Overlay cumulative equity curves for several backtest results.
results maps name -> BacktestResult. Each curve is direct-labeled at
its right end so identity never relies on color alone.
Source code in src/jaxfolio/viz/plots.py
plot_drawdown
¶
Underwater (drawdown) plot for one or more backtest results.
Source code in src/jaxfolio/viz/plots.py
plot_weight_evolution
¶
Stacked-area chart of weight evolution over a backtest.
Accepts a :class:BacktestResult or a weights DataFrame (dates x assets).
Source code in src/jaxfolio/viz/plots.py
plot_risk_contributions
¶
Bar chart of each asset's risk contribution (needs ERC metadata or recompute).
Source code in src/jaxfolio/viz/plots.py
plot_correlation_network
¶
Force-directed-style correlation network via the minimum spanning tree.
Nodes are assets placed on a circle; edges are the MST of the correlation
distance, plus any strong pairwise correlations above threshold. Node
size encodes degree centrality.
Source code in src/jaxfolio/viz/plots.py
368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 | |
plot_dendrogram
¶
Plot the HRP linkage dendrogram from a hierarchical_risk_parity result.
Source code in src/jaxfolio/viz/plots.py
plot_correlation_heatmap
¶
Clustered correlation heatmap (diverging blue↔red), optionally reordered.
Source code in src/jaxfolio/viz/plots.py
plot_metrics_table
¶
Render a metrics comparison table as a styled dark figure.
Source code in src/jaxfolio/viz/plots.py
plot_payoff
¶
Payoff-at-expiry diagram for an :class:OptionStrategy.
Profit region is shaded green, loss region red; break-even points and the reference spot are annotated.
Source code in src/jaxfolio/viz/plots.py
plot_greeks_profile
¶
plot_greeks_profile(
strategy,
*,
spot: float,
vol: float = 0.25,
rate: float = 0.0,
spread: float = 0.4,
greeks: tuple[str, ...] = (
"delta",
"gamma",
"vega",
"theta",
),
) -> Figure
Plot net position Greeks as a function of the underlying spot.
Source code in src/jaxfolio/viz/plots.py
plot_vol_surface
¶
Implied-volatility surface as a filled contour (strike x expiry -> IV).
ivs is a 2-D grid indexed [expiry, strike].
Source code in src/jaxfolio/viz/plots.py
dashboard
¶
Composite strategy-comparison report: KPI strip, equity, drawdown, frontier, table.
results maps name -> BacktestResult; highlight maps
name -> PortfolioResult for the frontier overlay. The layout is a clean
reporting grid — a headline KPI row for the best strategy (by Sharpe), the
equity and drawdown panels, and the efficient frontier beside a ranked
risk-adjusted (Sharpe) bar chart.
Source code in src/jaxfolio/viz/plots.py
637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 | |
save
¶
Theme¶
theme
¶
Dark matplotlib theme for jaxfolio.
Colors come from a validated, colorblind-considered palette (the reference
instance of the data-viz method): a fixed categorical order applied in-sequence
(never cycled arbitrarily), a single-hue blue sequential ramp for magnitude, and
neutral ink/grid tokens tuned for the dark chart surface #1a1a19.
Import side effect: calling :func:use_dark_theme (also invoked by
jaxfolio.viz on import) registers the rcParams globally.
color
¶
Return the categorical color for series index i (fixed order).
A 9th+ series intentionally wraps — callers with many series should fold to an "Other" bucket or use small multiples rather than rely on this wrap.
Source code in src/jaxfolio/viz/theme.py
use_dark_theme
¶
Register the jaxfolio dark theme as the active matplotlib rcParams.