API ReferenceEntry

outcome_plots

outcome_plots

Reference details for outcome_plots in causalis.shared.

outcome_plots

Functions
  • outcome_plot_boxplot – Prettified boxplot of the outcome by treatment.
  • outcome_plot_dist – Plot the distribution of the outcome for each treatment on a single, pretty plot.
  • outcome_plots – Plot the distribution of the outcome for every treatment on one plot,
outcome_plot_boxplot

Prettified boxplot of the outcome by treatment.

Features
  • High-DPI figure, scalable fonts
  • Soft modern color styling (default Matplotlib palette)
  • Optional outliers, gentle transparency
  • Optional save to PNG/SVG/PDF
Parameters
  • data (CausalData or MultiCausalData) – The causal dataset containing the dataframe and metadata.
  • treatment (str) – Treatment column name. For MultiCausalData, if not provided, one-hot treatment columns are converted to assigned treatment labels.
  • outcome (str) – Outcome column name. Defaults to the one in data_contracts.
  • figsize (tuple) – Figure size in inches (width, height).
  • dpi (int) – Dots per inch for the figure.
  • font_scale (float) – Scaling factor for all font sizes in the plot.
  • showfliers (bool) – Whether to show outliers (fliers).
  • patch_artist (bool) – Whether to fill boxes with color.
  • palette (list or dict) – Color palette for treatments (list in treatment order or dict {treatment: color}).
  • save (str) – Path to save the figure (e.g., "boxplot.png").
  • save_dpi (int) – DPI for the saved figure. Defaults to 300 for raster formats.
  • transparent (bool) – Whether to save the figure with a transparent background.
Returns
  • Figure – The generated figure object.
outcome_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
  • data (CausalData or MultiCausalData) – The causal dataset containing the dataframe and metadata.
  • treatment (str) – Treatment column name. For MultiCausalData, if not provided, one-hot treatment columns are converted to assigned treatment labels.
  • outcome (str) – Outcome column name. Defaults to the one in data_contracts.
  • bins (str or int) – Number of bins for histograms (e.g., "fd", "auto", or an integer).
  • density (bool) – Whether to normalize histograms to form a density.
  • alpha (float) – Transparency for overlaid histograms and bars.
  • sharex (bool) – If True, use the same x-limits across treatments for numeric outcomes.
  • kde (bool) – Whether to overlay a smooth density (KDE) for numeric outcomes.
  • clip (tuple) – Quantiles to trim tails for nicer view of numeric outcomes.
  • figsize (tuple) – Figure size in inches (width, height).
  • dpi (int) – Dots per inch for the figure.
  • font_scale (float) – Scaling factor for all font sizes in the plot.
  • palette (list or dict) – Color palette for treatments (list in treatment order or dict {treatment: color}).
  • save (str) – Path to save the figure (e.g., "outcome.png").
  • save_dpi (int) – DPI for the saved figure. Defaults to 300 for raster formats.
  • transparent (bool) – Whether to save the figure with a transparent background.
Returns
  • Figure – The generated figure object.
outcome_plots

Plot the distribution of the outcome for every treatment on one plot, and also produce a boxplot by treatment to visualize outliers.

Parameters
  • data (CausalData or MultiCausalData) – The causal dataset containing the dataframe and metadata.
  • treatment (str) – Treatment column name. Defaults to the one in data_contracts.
  • outcome (str) – Outcome column name. Defaults to the one in data_contracts.
  • bins (int) – Number of bins for histograms when the outcome is numeric.
  • density (bool) – Whether to normalize histograms to form a density.
  • alpha (float) – Transparency for overlaid histograms.
  • figsize (tuple) – Figure size for the plots (width, height).
  • sharex (bool) – If True and the outcome is numeric, use the same x-limits across treatments.
  • palette (list or dict) – Color palette for treatments (list in treatment order or dict {treatment: color}).
Returns