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_nameschains (
list, optional) – List of pandas DataFrames containing MCMC chains with ‘weight’ columnfisher_labels (
list, optional) – Labels for Fisher matrices in the plot legendchain_labels (
list, optional) – Labels for MCMC chains in the plot legendparams (
list, optional) – Parameters to plot. If None, uses all parameters from first Fisher/chaincolors (
list, optional) – Colors for each Fisher/chain. Defaults to a preset color schemetruth_values (
dict, optional) – Dictionary of true parameter values to plot as vertical linesshade_fisher (
boolorlist, optional) – Whether to shade Fisher contours. Can be single bool or list for each Fishershade_chains (
boolorlist, optional) – Whether to shade chain contours. Can be single bool or list for each chainls_fisher (
strorlist, optional) – Line style for Fisher contours. Can be single str or list for each Fisherlw_fisher (
floatorlist, optional) – Line width for Fisher contours. Can be single float or list for each Fisherfontsize (
int, optional) – Font size for legend and labelsparam_labels (
dict, optional) – Dictionary mapping parameter names to LaTeX labels. Default provides common cosmological parameterssmooth (
int, optional) – Smoothing factor for contourskde (
bool, optional) – Whether to use KDE for histogramsbins (
int, optional) – Number of bins for histogramsextents (
listordict, optional) – Parameter ranges to plot, as [min, max] for each parameterfigsize (
tuple, optional) – Figure size as (width, height) in inchestransform_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 shadingsave_plot (
bool, optional) – Whether to save the plotsavepath (
str, optional) – Directory to save plotplot_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 plotsavefile (
str, optional) – Complete filepath to save plot (overrides savepath, plot_filename, and file_format)
- Returns:
The generated triangle plot
- Return type:
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), ... } ... )