causalis.shared.outcome_plots.outcome_plot_distoutcome_plot_dist
Plot the distribution of the outcome for each treatment on a single, pretty plot.
Features
High-DPI canvas + scalable fonts
Default Matplotlib colors; KDE & mean lines match their histogram colors
Numeric outcomes: shared x-range (optional), optional KDE, quantile clipping
Categorical outcomes: normalized grouped bars by treatment
Binary outcomes: proportion bars with percent labels (no KDE)
Optional hi-res export (PNG/SVG/PDF)
Parameters
- dataCausalData or MultiCausalData
The causal dataset containing the dataframe and metadata.
- treatmentstr, optional
Treatment column name. For MultiCausalData, if not provided, one-hot treatment columns are converted to assigned treatment labels.
- outcomestr, optional
Outcome column name. Defaults to the one in
data_contracts.- binsstr or int, default “fd”
Number of bins for histograms (e.g., “fd”, “auto”, or an integer).
- densitybool, default True
Whether to normalize histograms to form a density.
- alphafloat, default 0.45
Transparency for overlaid histograms and bars.
- sharexbool, default True
If True, use the same x-limits across treatments for numeric outcomes.
- kdebool, default True
Whether to overlay a smooth density (KDE) for numeric outcomes.
- cliptuple, optional, default (0.01, 0.99)
Quantiles to trim tails for nicer view of numeric outcomes.
- figsizetuple, default (9, 5.5)
Figure size in inches (width, height).
- dpiint, default 220
Dots per inch for the figure.
- font_scalefloat, default 1.15
Scaling factor for all font sizes in the plot.
- palettelist or dict, optional
Color palette for treatments (list in treatment order or dict {treatment: color}).
- savestr, optional
Path to save the figure (e.g., “outcome.png”).
- save_dpiint, optional
DPI for the saved figure. Defaults to 300 for raster formats.
- transparentbool, default False
Whether to save the figure with a transparent background.
Returns
The generated figure object.
Canonical target
causalis.shared.outcome_plots.outcome_plot_dist
Sections