cosmicfish_pylib.fisher_plot

Module that contains a set of plotting tools.

class cosmicfish_pylib.fisher_plot.CosmicFishPlotter(settings=None, fishers=None, **kwargs)[source]

Main class for making plots from one or more Fisher matrices. All the functions create matplotlib objects that can later be accessed and modified.

Variables:
  • plot_fisherscosmicfish_pylib.fisher_plot_analysis.CosmicFish_FisherAnalysis containing the list of Fisher matrices that are being plotted.
  • plot_settingscosmicfish_pylib.fisher_plot_settings.CosmicFish_PlotSettings containing the plot settings that are used if not overwritten when plotting.
  • figurematplotlib.figure.Figure main figure object.
  • legendmatplotlib.legend.Legend legend object.
  • titlematplotlib.text.Text title object.
  • plot_gridmatplotlib.gridspec.GridSpec grid with the subplots. Created at initialization as empty and then arranged by plotting functions.
  • plot_dictdict dictionary containing the mapping of parameters and subplots matplotlib.axes._subplots.AxesSubplot.
  • plot_numberint number of plots.
  • bind_line_colorsdict dictionary mapping the names of the Fisher matrices to line colors. This is used to ensure consistency of settings and Fishers across plots.
  • bind_solid_colorsdict dictionary mapping the names of the Fisher matrices to solid colors. This is used to ensure consistency of settings and Fishers across plots.
  • bind_labelsdict dictionary mapping the names of the Fisher matrices to labels. This is used to ensure consistency of settings and Fishers across plots.
  • bind_linestyledict dictionary mapping the names of the Fisher matrices to line styles. This is used to ensure consistency of settings and Fishers across plots.

CosmicFishPlotter class constructor. The constructor will create the plotting objects based on the passed settings and Fisher matrices.

Parameters:
bind_plot_settings_to_names(names=None, **kwargs)[source]

This function binds settings to names using the default if something else is not supplied as a keyword argument.

Parameters:
  • names (string or a list of string) – a name of a fisher matrix or a list of names of fisher matrices to bind to settings. If None does all.
  • kwargs – optional keyword settings to bind to names.
close_plot()[source]

Closes the plot erasing everything that happened before.

export(filename, **kwargs)[source]

Export the plot to file. Almost just a wrapper to matplotlib.savefig

Parameters:
  • filename (string) – filename and path of the output file.
  • kwargs – optional keyword arguments directly fed to plt.savefig.
figure_1D(subplot, param, names, **kwargs)[source]

Creates a 1D gaussian plot of one parameter and with all the Fisher in names. Notice this is NOT one of the main plotting functions but rather used by other functions.

Parameters:
  • subplot (matplotlib.axes._subplots.AxesSubplot) – a subplot. The plot will be done here.
  • param (string) – the name of the parameter to plot.
  • names (string or a list of string) – a name of a Fisher matrix or a list of names of Fisher matrices. If None does none.
  • kwargs – optional keyword settings.
figure_2D(subplot, param1, param2, names, **kwargs)[source]

Creates a 2D gaussian ellipse plot of param1 and param2 and with all the Fisher in names. Notice this is NOT one of the main plotting functions but rather used by other functions.

Parameters:
  • subplot (matplotlib.axes._subplots.AxesSubplot) – a subplot. The plot will be done here.
  • param1 (string) – the name of the first parameter of the plot.
  • param2 (string) – the name of the second parameter of the plot.
  • names (string or a list of string) – a name of a Fisher matrix or a list of names of Fisher matrices. If None does none.
  • kwargs – optional keyword settings.
get_dimensions_plot_obj()[source]

This function computes the sizes in inches of all the objects in the figure to allow the computation of the figure spacings and disposition. Considers only the objects already present in the figure.

Returns:a dictionary with all the spacings.
Return type:dict
new_plot()[source]

Creates a new plot erasing everything that happened before. No need to call close_plot if you want to do another plot.

plot1D(params=None, names=None, title=None, **kwargs)[source]

Main 1D plotting function. This takes a set of parameter names, a set of fisher names and produces a figure with 1D plots. Uses settings in plot_settings but the resulting figure (figure) can be edited just like all matplotlib.pyplot figures. Optionally a title can be supplied and any kind of settings can be passed by kwargs.

Parameters:
  • params (string or a list of string) – a name of a parameter or a list of parameter names. If None does all.
  • names (string or a list of string) – a name of a fisher matrix or a list of names of fisher matrices. If None does all.
  • title (string) – the optional title for the plot.
  • kwargs – optional keyword settings.
plot2D(params=None, names=None, title=None, **kwargs)[source]

Main 2D plotting function. This takes a set of parameter names couples, a set of fisher names and produces a figure with 2D plots. Uses settings in plot_settings but the resulting figure (figure) can be edited just like all matplotlib.pyplot figures. Optionally a title can be supplied and any kind of settings can be passed by kwargs.

Parameters:
  • params (string or a list of string) – a couple of names of a parameter or a list of parameter names couples. If None does all.
  • names (string or a list of string) – a name of a fisher matrix or a list of names of fisher matrices. If None does all.
  • title (string) – the optional title for the plot.
  • kwargs – optional keyword settings.
plot3D(params=None, names=None, **kwargs)[source]

Main 3D plotting function. This takes a set of parameter names triplets, a set of fisher names and produces a figure with 3D plots. Uses settings in plot_settings but the resulting figure (figure) can be edited just like all matplotlib.pyplot figures. Optionally a title can be supplied and any kind of settings can be passed by kwargs.

Parameters:
  • params (string or a list of string) – a triplet of names of a parameter or a list of parameter names triplets. If None does all.
  • names (string or a list of string) – a name of a fisher matrix or a list of names of fisher matrices. If None does all.
  • title (string) – the optional title for the plot.
  • kwargs – optional keyword settings.
plot_mixed(params=None, names=None, **kwargs)[source]

Does mixed plot. This takes a set of parameter names, a set of fisher names and produces a figure with combined plots. Uses settings in plot_settings but the resulting figure (figure) can be edited just like all matplotlib.pyplot figures. Optionally a title can be supplied and any kind of settings can be passed by kwargs.

Parameters:
  • params (string or a list of string) – a name of a parameter or a list of parameter names. If None does nothing.
  • names (string or a list of string) – a name of a fisher matrix or a list of names of fisher matrices. If None does all.
  • title (string) – the optional title for the plot.
  • kwargs – optional keyword settings.
plot_tri(params=None, names=None, title=None, **kwargs)[source]

Main triangle plotting function. This takes a set of parameter names, a set of fisher names and produces a figure with triangular plots. Uses settings in plot_settings but the resulting figure (figure) can be edited just like all matplotlib.pyplot figures. Optionally a title can be supplied and any kind of settings can be passed by kwargs.

Parameters:
  • params (string or a list of string) – a list of names of a parameter. If None does all.
  • names (string or a list of string) – a name of a fisher matrix or a list of names of fisher matrices. If None does all.
  • title (string) – the optional title for the plot.
  • kwargs – optional keyword settings.
set_legend(names=None, **kwargs)[source]

Creates the legend of the plot.

Parameters:
  • names (string or a list of string) – a name of a fisher matrix or a list of names of fisher matrices. If None does all.
  • kwargs – optional keyword settings.
set_plot_dimensions(num_col, num_rows, **kwargs)[source]

Sets the dimensions of the plot based on the settings passed.

Parameters:
  • num_col (int) – number of colums in the plot grid.
  • num_rows (int) – number of rows in the plot grid.
  • kwargs – optional keyword settings
set_title(title=None, **kwargs)[source]

Creates the title of the plot.

Parameters:
  • names (string or a list of string) – a name of a fisher matrix or a list of names of fisher matrices. If None does all.
  • kwargs – optional keyword settings.
set_triplot_dimensions(num_col, num_rows, **kwargs)[source]

Sets the dimensions of the triangular plot based on the settings passed. This is different from the other dimension setter because triplots need some personalization.

Parameters:
  • num_col (int) – number of colums in the plot grid.
  • num_rows (int) – number of rows in the plot grid.
  • kwargs – optional keyword settings
setting_setter(key, **kwargs)[source]

Small utility to check wether a specific setting is in plot_settings or is passed as a keyword argument (in kwargs).

Parameters:
  • key (string) – input setting keyword
  • kwargs – keyword arguments to check
Returns:

the value of the setting. If the setting is present in kwargs then the value in there otherwise the value in cosmicfish_pylib.fisher_plot.CosmicFishPlotter.plot_settings