A comprehensive visualization package for risk analysis with ridge plots, heatmaps, waterfall charts, and time series tools
Project description
RiskPlot
A comprehensive Python package for risk analysis visualization, featuring ridge plots, heatmaps, waterfall charts, network diagrams, globe visualizations, and surface plots.
🚀 Features
Core Visualizations
- Ridge Plots: Distribution comparisons across categories
- Heatmaps: Correlation matrices and risk matrices
- Waterfall Charts: Risk attribution and P&L decomposition
- Time Series: VaR tracking and drawdown analysis
Advanced Visualizations ✨
- Network Plots: Entity relationship networks (requires
networkx) - Globe Visualizations: Interactive geographic risk mapping (requires
plotly) - Surface Plots: 2D/3D risk landscapes (requires
plotly,scipy)
🎯 Use Cases
- Financial Risk Management: Portfolio analysis, VaR calculations, stress testing
- Country Risk Analysis: Geographic risk assessment and monitoring
- Network Analysis: Financial interconnectedness, trade relationships
- Regulatory Reporting: Risk visualization for compliance and reporting
📦 Installation
Basic Installation
pip install riskplot
With Optional Dependencies
# For network visualizations
pip install riskplot[network]
# For globe visualizations
pip install riskplot[globe]
# For all features
pip install riskplot[all]
⚡ Quick Start
import riskplot
import pandas as pd
import numpy as np
# Create sample data
data = pd.DataFrame({
'category': ['Portfolio A', 'Portfolio B', 'Portfolio C'],
'returns': [np.random.normal(0.05, 0.1, 100),
np.random.normal(0.03, 0.08, 100),
np.random.normal(0.07, 0.15, 100)]
})
# Ridge plot
fig, ax = riskplot.ridge_plot(data, 'category', 'returns')
# Correlation heatmap
correlation_matrix = pd.DataFrame(np.random.rand(5, 5))
fig, ax = riskplot.correlation_heatmap(correlation_matrix)
# Network visualization (requires networkx)
network_data = pd.DataFrame({
'source': ['A', 'B', 'C'],
'target': ['B', 'C', 'A'],
'weight': [0.8, 1.2, 0.5]
})
fig, ax = riskplot.country_interaction_network(network_data)
# Interactive globe (requires plotly)
country_data = pd.DataFrame({
'country': ['USA', 'CHN', 'GBR'],
'risk_score': [0.3, 0.7, 0.4]
})
fig = riskplot.country_risk_globe(country_data)
fig.show()
Chart Types
Ridge Plots
# Basic ridge plot
rp.ridge_plot(data, 'category', 'value')
# Dual group comparison
rp.ridge_plot(data, 'category', 'value', 'group')
Heatmaps
# Correlation matrix
rp.correlation_heatmap(data)
# Risk matrix
rp.risk_matrix(data, 'probability', 'impact', 'label')
# Exposure heatmap
rp.exposure_heatmap(data, 'entity', 'sector', 'exposure')
Waterfall Charts
# Risk attribution
rp.risk_attribution_waterfall(data, 'factor', 'contribution')
# P&L waterfall
rp.pnl_waterfall(data, 'component', 'amount')
# VaR decomposition
rp.var_decomposition(data, 'component', 'var_contribution')
Distribution Plots
# Violin plots
violin = rp.ViolinPlot()
fig, ax = violin.plot(data, 'category', 'value')
# Distribution summary
rp.risk_distribution_summary(data, 'returns')
Time Series
# Rolling risk metrics
rp.rolling_risk_metrics(data, 'date', 'returns')
# Drawdown analysis
drawdown = rp.DrawdownChart()
fig, axes = drawdown.plot(data, 'date', 'value', show_underwater=True)
Advanced Usage
Custom Configuration
config = rp.PlotConfig(
figsize=(12, 8),
colormap='plasma',
style='seaborn'
)
# Use with any visualization class
heatmap = rp.RiskHeatmap(config=config)
Extending the Framework
class CustomRiskPlot(rp.RiskVisualization):
def plot(self, data, **kwargs):
fig, ax = self._setup_figure(**kwargs)
# Your custom plotting logic
return fig, ax
Examples
examples/basic_usage.py- Basic functionality demonstrationexamples/recreate_original.py- Recreates original ridge plot exampleexamples/comprehensive_demo.py- Complete feature showcase
📚 Documentation
- Getting Started Guide: Installation and basic usage
- API Reference: Complete function documentation
- Examples Gallery: Comprehensive examples
- Advanced Features: Power user techniques
🧪 Dependencies
Core Dependencies
matplotlib >= 3.5.0pandas >= 1.3.0numpy >= 1.20.0scipy >= 1.7.0
Optional Dependencies
networkx >= 2.6.0(for network visualizations)plotly >= 5.0.0(for globe and interactive surface plots)
🤝 Contributing
We welcome contributions! Please see our Contributing Guide for details.
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
🔗 Links
Made with ❤️ for the risk management community
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file riskplot-0.2.0.tar.gz.
File metadata
- Download URL: riskplot-0.2.0.tar.gz
- Upload date:
- Size: 4.3 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
270bafbec370336584d8656c543d8790a2683b409ac9fdac2b9baab6bacc1910
|
|
| MD5 |
2f92238e79cb9a58b84de52c98a60b87
|
|
| BLAKE2b-256 |
dcad3cbf946aab07b1b72a456f438ded4bf941b1e943a05aab5ba04149454548
|
Provenance
The following attestation bundles were made for riskplot-0.2.0.tar.gz:
Publisher:
publish-to-pypi.yml on OwenDinsmore/riskplot
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
riskplot-0.2.0.tar.gz -
Subject digest:
270bafbec370336584d8656c543d8790a2683b409ac9fdac2b9baab6bacc1910 - Sigstore transparency entry: 545810906
- Sigstore integration time:
-
Permalink:
OwenDinsmore/riskplot@47f843f1bef10eefff1300598ec93a1d3bbcc566 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/OwenDinsmore
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@47f843f1bef10eefff1300598ec93a1d3bbcc566 -
Trigger Event:
release
-
Statement type:
File details
Details for the file riskplot-0.2.0-py3-none-any.whl.
File metadata
- Download URL: riskplot-0.2.0-py3-none-any.whl
- Upload date:
- Size: 31.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f719c94ff9af2ddda38da3912edadc1c87bb925fd8012ea94349f28d9b8ec36a
|
|
| MD5 |
03c8888f02ecb031a7123d1ef0ee55f1
|
|
| BLAKE2b-256 |
95619105ec5f01cd9585baf96ebfcfe78fa5f1a46e511312e86c980d8144870a
|
Provenance
The following attestation bundles were made for riskplot-0.2.0-py3-none-any.whl:
Publisher:
publish-to-pypi.yml on OwenDinsmore/riskplot
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
riskplot-0.2.0-py3-none-any.whl -
Subject digest:
f719c94ff9af2ddda38da3912edadc1c87bb925fd8012ea94349f28d9b8ec36a - Sigstore transparency entry: 545810935
- Sigstore integration time:
-
Permalink:
OwenDinsmore/riskplot@47f843f1bef10eefff1300598ec93a1d3bbcc566 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/OwenDinsmore
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@47f843f1bef10eefff1300598ec93a1d3bbcc566 -
Trigger Event:
release
-
Statement type: