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_fishers –
cosmicfish_pylib.fisher_plot_analysis.CosmicFish_FisherAnalysis
containing the list of Fisher matrices that are being plotted. - plot_settings –
cosmicfish_pylib.fisher_plot_settings.CosmicFish_PlotSettings
containing the plot settings that are used if not overwritten when plotting. - figure –
matplotlib.figure.Figure
main figure object. - legend –
matplotlib.legend.Legend
legend object. - title –
matplotlib.text.Text
title object. - plot_grid –
matplotlib.gridspec.GridSpec
grid with the subplots. Created at initialization as empty and then arranged by plotting functions. - plot_dict –
dict
dictionary containing the mapping of parameters and subplotsmatplotlib.axes._subplots.AxesSubplot
. - plot_number –
int
number of plots. - bind_line_colors –
dict
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_colors –
dict
dictionary mapping the names of the Fisher matrices to solid colors. This is used to ensure consistency of settings and Fishers across plots. - bind_labels –
dict
dictionary mapping the names of the Fisher matrices to labels. This is used to ensure consistency of settings and Fishers across plots. - bind_linestyle –
dict
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: - settings (
cosmicfish_pylib.fisher_plot_settings.CosmicFish_PlotSettings
ordict
) – an instance of CosmicFish_PlotSettings or a dictionary containing the plot settings. - fishers (
cosmicfish_pylib.fisher_plot_analysis.CosmicFish_FisherAnalysis
) – an instance of fisher_plot.analysis.CosmicFish_FisherAnalysis containing a series of fisher matrices. - kwargs – these contain the possibility of passing additional options or other options that would override the ones in settings.
-
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 alist
ofstring
) – 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.
- names (
-
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.
- filename (
-
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 alist
ofstring
) – a name of a Fisher matrix or a list of names of Fisher matrices. If None does none. - kwargs – optional keyword settings.
- subplot (
-
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 alist
ofstring
) – a name of a Fisher matrix or a list of names of Fisher matrices. If None does none. - kwargs – optional keyword settings.
- subplot (
-
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 alist
ofstring
) – a name of a parameter or a list of parameter names. If None does all. - names (
string
or alist
ofstring
) – 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.
- params (
-
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 alist
ofstring
) – a couple of names of a parameter or a list of parameter names couples. If None does all. - names (
string
or alist
ofstring
) – 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.
- params (
-
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 alist
ofstring
) – a triplet of names of a parameter or a list of parameter names triplets. If None does all. - names (
string
or alist
ofstring
) – 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.
- params (
-
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 alist
ofstring
) – a name of a parameter or a list of parameter names. If None does nothing. - names (
string
or alist
ofstring
) – 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.
- params (
-
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:
-
set_legend
(names=None, **kwargs)[source]¶ Creates the legend of the plot.
Parameters: - names (
string
or alist
ofstring
) – a name of a fisher matrix or a list of names of fisher matrices. If None does all. - kwargs – optional keyword settings.
- names (
-
set_plot_dimensions
(num_col, num_rows, **kwargs)[source]¶ Sets the dimensions of the plot based on the settings passed.
Parameters:
-
set_title
(title=None, **kwargs)[source]¶ Creates the title of the plot.
Parameters: - names (
string
or alist
ofstring
) – a name of a fisher matrix or a list of names of fisher matrices. If None does all. - kwargs – optional keyword settings.
- names (
-
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:
-
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
- key (
- plot_fishers –