elisa.plot.plotter#
Visualize fit and analysis results.
- class PlotConfig(alpha: float = 0.8, palette: Any = 'colorblind', xscale: Literal['linear', 'log'] = 'log', yscale: Literal['linear', 'log', 'linlog'] = 'linlog', lin_frac: float = 0.15, cl: tuple[float, ...] = (0.683, 0.95), residuals: Literal['rd', 'rp', 'rq'] = 'rq', random_quantile: bool = False, mark_outlier_residuals: bool = False, residuals_ci_with_sign: bool = True, fill_residuals_ci: bool = True, plot_comps: bool = False, seed: int | None = None)[source]#
Bases:
objectPlotting configuration.
Attributes
Transparency of colors.
Confidence/Credible level.
Whether to fill residuals' CI bands.
Linear fraction of the
linlogplot.Whether to mark outlier residuals with red crosses.
Color palettes, see [1] for details.
Whether to plot additive components in spectral plot.
Whether to randomize the quantile residual.
Default type of residual plot.
Whether to take account residuals' sign when calculate CI bands.
Random seed used in calculation.
X-axis scale of spectral plot.
X-axis scale of spectral plot.
- property xscale: Literal['linear', 'log']#
X-axis scale of spectral plot.
Should be
'linear', or'log'.
- property yscale: Literal['linear', 'log', 'linlog']#
X-axis scale of spectral plot.
Should be
'linear','log', or'linlog'.
- class Plotter(result: FitResult, config: PlotConfig = None)[source]#
Bases:
ABCPlotter to visualize fit results.
Attributes
Plotting color for each data.
LaTeX representation of components.
Plotting configuration.
Data points number.
Label of parameters.
LaTeX representation of parameters.
Title of parameters.
Unit of parameters.
data
Methods
__call__([plots])Call self as a function.
get_plot_data(result)Get PlotData from FitResult.
plot_ce(ax)Plot data.
plot_corner(*args, **kwargs)Corner plot of bootstrap/posterior parameters.
plot_folded(ax)Plot folded model.
plot_gof()Plot distribution of GOF statistics and p-value.
plot_pit([detrend])Probability integral transformation empirical CDF plot.
plot_qq([rtype, seed, detrend])Quantile-Quantile plot.
plot_residuals(ax[, rtype])Plot residuals.
plot_spec([data, ne, ene, eene, residuals, ...])Spectral plot.
plot_unfolded(ax, mtype[, params, egrid, ...])Plot unfolded model.
set_colors([colors])Specify the colors of data points used in the plots.
set_xlabel
- abstractmethod plot_corner(*args, **kwargs) Figure[source]#
Corner plot of bootstrap/posterior parameters.
- abstractmethod static get_plot_data(result: FitResult) dict[str, PlotData][source]#
Get PlotData from FitResult.
- property config: PlotConfig#
Plotting configuration.
- set_colors(colors: dict[str, Any] | None = None)[source]#
Specify the colors of data points used in the plots.
- property colors#
Plotting color for each data.
- property ndata#
Data points number.
- plot_spec(data: bool = True, ne: bool = True, ene: bool = False, eene: bool = False, residuals: bool | Literal['rd', 'rp', 'rq'] = True, *, egrid: Mapping[str, ndarray] | None = None, params: Mapping[str, float | int | ndarray | Array] | None = None, label_Fv: bool = False, label_vFv: bool = False, label_FvJy: bool = False) Figure[source]#
Spectral plot.
- Parameters:
- databool, optional
Whether to plot folded model and data. The default is
True.- nebool, optional
Whether to plot \(N(E)\). The default is
True.- enebool, optional
Whether to plot \(E N(E)\). The default is
False.- eenebool, optional
Whether to plot \(E^2 N(E)\). The default is
False.- residualsbool or {‘rd’, ‘rp’, ‘rq’}, optional
Whether to plot residuals. Available options are:
True: plot default residualsFalse: do not plot residuals'rd': plot deviance residuals'rp': plot Pearson residuals'rq': plot quantile residuals
The default is
True.- egrid
dict, optional Overwrite the photon energy grid when plotting unfolded model.
- params
dict, optional Overwrite the photon energy grid when plotting unfolded model.
- label_Fvbool, optional
Whether to label the y-axis of \(E N(E)\) plot as \(F_{\nu}\). The default is
False.- label_vFvbool, optional
Whether to label the y-axis of \(E^2 N(E)\) plot as \(\nu F_{\nu}\). The default is
False.- label_FvJybool, optional
Whether to label the y-axis of \(E N(E)\) plot as \(F_{\nu}\) in Jy and convert values to Jy. The default is
False.
- Returns:
FigureThe Figure object containing the spectral plot.
- plot_unfolded(ax: Axes, mtype: Literal['ne', 'ene', 'eene'], params: Mapping[str, float | int | ndarray | Array] | None = None, egrid: Mapping[str, ndarray] | None = None, label_Fv: bool = False, label_vFv: bool = False, label_FvJy: bool = False)[source]#
Plot unfolded model.
- Parameters:
- ax
Axes The Axes object to plot.
- mtype{‘ne’, ‘ene’, ‘eene’}
The type of unfolded model, available options are:
'ne': plot \(N(E)\)'ene': plot \(E N(E)\)'eene': plot \(E^2 N(E)\)
- params
dict, optional Overwrite the parameters when plotting unfolded model.
- egrid
dict, optional Overwrite the photon energy grid when plotting unfolded model.
- label_Fvbool, optional
Whether to label the y-axis of \(E N(E)\) plot as \(F_{\nu}\). The default is
False.- label_vFvbool, optional
Whether to label the y-axis of \(E^2 N(E)\) plot as \(\nu F_{\nu}\). The default is
False.- label_FvJybool, optional
Whether to label the y-axis of \(E N(E)\) plot as \(F_{\nu}\) in Jy and convert values to Jy. The default is
False.
- ax
- plot_residuals(ax: Axes, rtype: Literal['rd', 'rp', 'rq'] | None = None)[source]#
Plot residuals.
- Parameters:
- ax
Axes The Axes object to plot.
- rtype{‘rd’, ‘rp’, ‘rq’}, optional
The type of residuals, available options are:
'rd': deviance residuals'rp': Pearson residuals'rq': quantile residuals
- ax
- plot_qq(rtype: Literal['rd', 'rp', 'rq'] | None = None, seed: int | None = None, detrend: bool = True) Figure[source]#
Quantile-Quantile plot.
- Parameters:
- rtype{‘rd’, ‘rp’, ‘rq’}, optional
The type of residuals, available options are:
'rd': deviance residuals'rp': Pearson residuals'rq': quantile residualsNone: use the default residuals type
The default is
None.- seed
int, optional Random seed used in calculation. The default is
None.- detrendbool, optional
Whether to detrend the Q-Q plot. The default is
True.
- Returns:
FigureThe Figure object containing Q-Q plot.
- class MLEResultPlotter(result: FitResult, config: PlotConfig = None)[source]#
Bases:
PlotterAttributes
colorsPlotting color for each data.
comps_latexLaTeX representation of components.
configPlotting configuration.
ndataData points number.
params_labelsLabel of parameters.
params_latexLaTeX representation of parameters.
params_titlesTitle of parameters.
params_unitUnit of parameters.
data
Methods
__call__([plots])Plot MLE fit results.
get_plot_data(result)Get PlotData from FitResult.
plot_ce(ax)Plot data.
plot_corner([params, color, bins, ...])Corner plot of bootstrap parameters.
plot_folded(ax)Plot folded model.
plot_gof()Plot distribution of GOF statistics and p-value.
plot_pit([detrend])Probability integral transformation empirical CDF plot.
plot_qq([rtype, seed, detrend])Quantile-Quantile plot.
plot_residuals(ax[, rtype])Plot residuals.
plot_spec([data, ne, ene, eene, residuals, ...])Spectral plot.
plot_unfolded(ax, mtype[, params, egrid, ...])Plot unfolded model.
set_colors([colors])Specify the colors of data points used in the plots.
set_xlabel
- static get_plot_data(result: MLEResult) dict[str, MLEPlotData][source]#
Get PlotData from FitResult.
- plot_corner(params: str | Sequence[str] | None = None, color: str | None = None, bins: int | Sequence[int] = 40, hist_bin_factor: float | Sequence[float] = 1.5, fig_path: str | None = None) Figure[source]#
Corner plot of bootstrap parameters.
- Parameters:
- params
stror sequenceofstr, optional Parameters to plot. The default is all spectral parameters.
- color
str, optional Color of the plot. The default is
None.- bins
intorlistofint, optional The number of bins to use in histograms, either as a fixed value for all dimensions or as a list of integers for each dimension. The default is 40.
- hist_bin_factor
floatorlistoffloat, optional This is a factor (or list of factors, one for each dimension) that will multiply the bin specifications when making the 1-D histograms. This is generally used to increase the number of bins in the 1-D plots to provide more resolution. The default is 1.5.
- fig_path
str, optional Path to save the figure. The default is
None.
- params
- Returns:
FigureThe Figure object containing corner plot.
- class PosteriorResultPlotter(result: FitResult, config: PlotConfig = None)[source]#
Bases:
PlotterAttributes
colorsPlotting color for each data.
comps_latexLaTeX representation of components.
configPlotting configuration.
ndataData points number.
params_labelsLabel of parameters.
params_latexLaTeX representation of parameters.
params_titlesTitle of parameters.
params_unitUnit of parameters.
data
Methods
__call__([plots])Plot Bayesian fit results.
get_plot_data(result)Get PlotData from FitResult.
plot_ce(ax)Plot data.
plot_corner([params, color, divergences, ...])Corner plot of posterior parameters.
plot_folded(ax)Plot folded model.
plot_gof()Plot distribution of GOF statistics and p-value.
Plot k-hat diagnostic of PSIS-LOO.
plot_pit([detrend])Probability integral transformation empirical CDF plot.
plot_qq([rtype, seed, detrend])Quantile-Quantile plot.
plot_residuals(ax[, rtype])Plot residuals.
plot_spec([data, ne, ene, eene, residuals, ...])Spectral plot.
plot_trace([params, fig_path])Plot trace plot of posterior samples.
plot_unfolded(ax, mtype[, params, egrid, ...])Plot unfolded model.
set_colors([colors])Specify the colors of data points used in the plots.
set_xlabel
- static get_plot_data(result: PosteriorResult) dict[str, PosteriorPlotData][source]#
Get PlotData from FitResult.
- plot_trace(params: str | Sequence[str] | None = None, fig_path: str | None = None) Figure[source]#
Plot trace plot of posterior samples.
- plot_corner(params: str | Sequence[str] | None = None, color: str | None = None, divergences: bool = True, bins: int | Sequence[int] = 40, hist_bin_factor: float | Sequence[float] = 1.5, fig_path: str | None = None) Figure[source]#
Corner plot of posterior parameters.
- Parameters:
- params
stror sequenceofstr, optional Parameters to plot. The default is all spectral parameters.
- color
str, optional Color of the plot. The default is
None.- divergencesbool, optional
Whether to show divergent samples. The default is
True.- bins
intorlistofint, optional The number of bins to use in histograms, either as a fixed value for all dimensions, or as a list of integers for each dimension. The default is 40.
- hist_bin_factor
floatorlistoffloat, optional This is a factor (or list of factors, one for each dimension) that will multiply the bin specifications when making the 1-D histograms. This is generally used to increase the number of bins in the 1-D plots to provide more resolution. The default is 1.5.
- fig_path
str, optional Path to save the figure. The default is
None.
- params
- Returns:
FigureThe Figure object containing corner plot.