Welcome to cantuccio’s documentation!
cantuccio: yet another corner plot library
can·tuc·cio | /kan’tutːʃo/ noun [masculine]
an Italian biscuit from Tuscany.
corner, nook.
cantuccio is a Python library for creating corner plots, automatically handling the layout and size of labels, ticks, and legends. It is designed to be flexible and easy to use, allowing users to create publication-quality corner plots with minimal code. When dealing with large datasets, cantuccio can utilize the KDEpy package for faster KDE estimation.
Visual choices are inspired by many of the existing corner plot libraries, with particular credit to corner, chainconsumer, cornetto, and makecorner.
Installation
You can install cantuccio using pip:
This project is managed by uv. To set up the development environment, install uv if needed:
curl -LsSf https://astral.sh/uv/install.sh | sh
Then, clone the repository and install the package in editable mode:
git clone https://github.com/asantini29/cantuccio
cd cantuccio
uv sync
uv run pip install -e .
Alternatively, you can install the latest version directly from PyPI:
pip install cantuccio
Example
Here is a simple example of how to use cantuccio to create a corner plot:
import numpy as np
import cantuccio as ct
# Generate some random data
data = np.random.randn(1000, 3)
labels = ['x', 'y', 'z']
data_dict = {label: data[:, i] for i, label in enumerate(labels)}
# Create a corner plot
fig, axs = ct.cornerplot(data_dict)
fig.show()
AI Statement
This project made use of generative AI. All the outputs have been reviewed and edited to ensure quality and consistency.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Documentation:
Tutorial:
- Start generating some data
- let’s see how they look
- We can now change the style…
- … change the KDE estimation method to use
KDEpy’sFFTKDE… - … add the true values…
- … plot the difference between data and injection …
- … add a second chain …
- … and label them …
- If the ticks overlap, we can decrease their number
- Chains do not have to share the same parameters, but we can still plot them together
- Now let’s see how the corner plot looks for higly correlated parameters under the two KDE estimation methods.
- And against the histogram:
- Median-symmetric vs highest-density credible intervals
- We can also overlay a covariance matrix ellipse on top of our corner plot if we have it available: