make_triangle_plot#

cosmicjellyfish.analysis.fishconsumer.make_triangle_plot(fishers=None, chains=None, fisher_labels=None, chain_labels=None, params=None, colors=None, truth_values=None, shade_fisher=False, shade_chains=True, ls_fisher='-', lw_fisher=2.5, legend_kwargs={'fontsize': 20, 'loc': 'upper right'}, param_labels={}, label_font_size=20, tick_font_size=16, smooth=3, kde=False, bins=None, extents={}, figsize=None, transform_params=None, shade_alpha=0.4, save_plot=False, savepath='./', plot_filename=None, file_format='.pdf', save_dpi=200, savefile=None)[source]#

Create a triangle plot from Fisher matrices and/or MCMC chains using ChainConsumer.

Parameters:
  • fishers (list, optional) – List of Fisher matrix objects with attributes param_fiducial, fisher_matrix_inv, param_names

  • chains (list, optional) – List of pandas DataFrames containing MCMC chains with ‘weight’ column

  • fisher_labels (list, optional) – Labels for Fisher matrices in the plot legend

  • chain_labels (list, optional) – Labels for MCMC chains in the plot legend

  • params (list, optional) – Parameters to plot. If None, uses all parameters from first Fisher/chain

  • colors (list, optional) – Colors for each Fisher/chain. Defaults to a preset color scheme

  • truth_values (dict, optional) – Dictionary of true parameter values to plot as vertical lines

  • shade_fisher (bool or list, optional) – Whether to shade Fisher contours. Can be single bool or list for each Fisher

  • shade_chains (bool or list, optional) – Whether to shade chain contours. Can be single bool or list for each chain

  • ls_fisher (str or list, optional) – Line style for Fisher contours. Can be single str or list for each Fisher

  • lw_fisher (float or list, optional) – Line width for Fisher contours. Can be single float or list for each Fisher

  • fontsize (int, optional) – Font size for legend and labels

  • param_labels (dict, optional) – Dictionary mapping parameter names to LaTeX labels. Default provides common cosmological parameters

  • smooth (int, optional) – Smoothing factor for contours

  • kde (bool, optional) – Whether to use KDE for histograms

  • bins (int, optional) – Number of bins for histograms

  • extents (list or dict, optional) – Parameter ranges to plot, as [min, max] for each parameter

  • figsize (tuple, optional) – Figure size as (width, height) in inches

  • transform_params (dict, optional) –

    Dictionary to transform parameters, with required keys:

    ’param’: parameter name to transform ‘transform_param’: name of transformed parameter ‘transform_func’: function to apply to parameter samples

    And optional keys:

    ’transform_param_latex’: latex name of transformed parameter

  • shade_alpha (float, optional) – Alpha (transparency) for contour shading

  • save_plot (bool, optional) – Whether to save the plot

  • savepath (str, optional) – Directory to save plot

  • plot_filename (str, optional) – Filename for saved plot (without extension)

  • file_format (str, optional) – File format for saved plot (default: ‘.pdf’)

  • save_dpi (int, optional) – DPI for saved plot

  • savefile (str, optional) – Complete filepath to save plot (overrides savepath, plot_filename, and file_format)

Returns:

The generated triangle plot

Return type:

matplotlib.figure.Figure

Examples

>>> # Plot just Fisher matrices
>>> fig = make_triangle_plot(
...     fishers=[fisher1, fisher2],
...     fisher_labels=['SKAO', 'Euclid']
... )
>>> # Plot Fisher matrices and chains
>>> fig = make_triangle_plot(
...     fishers=[fisher1],
...     chains=[chain_df],
...     fisher_labels=['Fisher'],
...     chain_labels=['MCMC'],
...     truth_values={'Omegam': 0.3, 'h': 0.7}
... )
>>> # Plot with parameter transformation
>>> fig = make_triangle_plot(
...     fishers=[fisher1],
...     fisher_labels=['Fisher'],
...     transform_params={
...         'param': 'sigma8',
...         'transform_param': 'S8',
...         'transform_param_latex': r'$S_8$',
...         'transform_func': lambda x: x * np.sqrt(0.3/x),
...     }
... )