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:
data (
bool) – Whether to plot folded model and data. The default isTrue.ne (
bool) – Whether to plot \(N(E)\). The default isTrue.ene (
bool) – Whether to plot \(E N(E)\). The default isFalse.eene (
bool) – Whether to plot \(E^2 N(E)\). The default isFalse.residuals – Whether to plot residuals. Available options are:
- Returns:
The 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 – The type of unfolded model, available options are:
- plot_qq(rtype: Literal['rd', 'rp', 'rq'] | None = None, seed: int | None = None, detrend: bool = True) Figure[source]#
Quantile-Quantile plot.
- Parameters:
rtype – The type of residuals, available options are:
- Returns:
The 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 (
str|Sequence[str] |None) – Parameters to plot. The default is all spectral parameters.color (
str|None) – Color of the plot. The default isNone.bins (
int|Sequence[int]) – 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 (
float|Sequence[float]) – 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|None) – Path to save the figure. The default isNone.
- Returns:
The 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 (
str|Sequence[str] |None) – Parameters to plot. The default is all spectral parameters.color (
str|None) – Color of the plot. The default isNone.divergences (
bool) – Whether to show divergent samples. The default isTrue.bins (
int|Sequence[int]) – 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 (
float|Sequence[float]) – 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|None) – Path to save the figure. The default isNone.
- Returns:
The Figure object containing corner plot.