swyft.plot¶
- swyft.plot.corner(marginal_1d, marginal_2d, figsize=None, bins=100, kde=False, xlim=None, ylim_lower=None, truth=None, levels=3, labels=None, ticks=True, ticklabels=True, ticklabelsize='x-small', tickswhich='both', labelrotation=45.0, space_between_axes=0.1)[source]¶
create a corner plot from a dictionary of marginals
- Parameters:
marginal_1d (Union[WeightedMarginalSamples, Dict[Tuple[int, ...], Union[ndarray, Tensor]], Dict[Tuple[int, ...], DataFrame]]) – one dimensional marginal samples, weighted samples, or dataframes
marginal_2d (Union[WeightedMarginalSamples, Dict[Tuple[int, ...], Union[ndarray, Tensor]], Dict[Tuple[int, ...], DataFrame]]) – two dimensional marginal samples, weighted samples, or dataframes
figsize (Optional[Tuple[float, float]]) – choose the figsize. like matplotlib.
bins (int) – number of bins for the histogram
kde (Optional[bool]) – do a kernel density estimate to produce isocontour lines? (may be expensive)
xlim (Optional[Union[Tuple[Real, Real], Sequence[Tuple[Real, Real]]]]) – set the xlim. either a single tuple for the same value on all plots, or a sequence of tuples for every column in the plot.
ylim_lower (Optional[Union[Tuple[Real, Real], Sequence[Tuple[Real, Real]]]]) – set the ylim for the 2d histograms on the lower triangle. either a single tuple for the same value on all plots, or a sequence of tuples for every row in the plot. first row is not considered.
truth (Optional[Union[ndarray, Tensor]]) – array denoting the true parameter which generated the observation.
levels (int) – number of isocontour lines to plot. only functions when kde=True.
labels (Optional[Sequence[str]]) – the string labels for the parameters.
ticks (bool) – whether to show ticks on the bottom row and leftmost column
ticklabels (bool) – whether to show the value of the ticks bottom row and leftmost column. only functions when ticks=True.
ticklabelsize (str) – set size of tick labels. see plt.tick_params
tickswhich (str) – whether to affect major or minor ticks. see plt.tick_params
labelrotation (float) – tick label rotation. see plt.tick_params
space_between_axes (float) – changes the wspace and hspace between subplots. see plt.subplots_adjust
- Returns:
matplotlib figure, np array of matplotlib axes
- Return type:
Tuple[Figure, ndarray]
- swyft.plot.empirical_z_score_corner(empirical_mass_1d, empirical_mass_2d, max_z_score=3.5, labels=None, figsize=None, space_between_axes=0.1)[source]¶
create a corner plot with each subplot containing a p-p test of expected coverage probability
- Parameters:
empirical_mass_1d (Dict[Tuple[int, ...], Union[ndarray, Tensor]]) – empirical mass dict from marginal_indices to array
empirical_mass_2d (Dict[Tuple[int, ...], Union[ndarray, Tensor]]) – empirical mass dict from marginal_indices to array
max_z_score (float) – maximum nominal z-score to plot. Defaults to 3.5.
labels (Optional[Sequence[str]]) – for labeling the x and y axes. Defaults to None.
figsize (Optional[Tuple[float, float]]) – set figsize like in plt.subplots. Defaults to None.
space_between_axes (float) – changes the wspace and hspace between subplots. see plt.subplots_adjust. Defaults to 0.1.
- Returns:
matplotlib figure, np array of matplotlib axes
- Return type:
Tuple[Figure, Axes]
- swyft.plot.hist1d(marginal_1d, figsize=None, bins=100, kde=False, xlim=None, ylim=None, truth=None, labels=None, ticks=True, ticklabels=True, ticklabelsize='x-small', tickswhich='both', labelrotation=45.0, space_between_axes=0.1)[source]¶
create a row of 1d histograms from marginals
- Parameters:
marginal_1d (Union[WeightedMarginalSamples, Dict[Tuple[int, ...], Union[ndarray, Tensor]], Dict[Tuple[int, ...], DataFrame]]) – one dimensional marginal samples, weighted samples, or dataframes
figsize (Optional[Tuple[float, float]]) – choose the figsize. like matplotlib.
bins (int) – number of bins for the histogram
kde (Optional[bool]) – do a kernel density estimate to produce isocontour lines? (may be expensive)
xlim (Optional[Union[Tuple[Real, Real], Sequence[Tuple[Real, Real]]]]) – set the xlim. either a single tuple for the same value on all plots, or a sequence of tuples for every plot.
ylim (Optional[Union[Tuple[Real, Real], Sequence[Tuple[Real, Real]]]]) – set the ylim. either a single tuple for the same value on all plots, or a sequence of tuples for every plot.
truth (Optional[Union[ndarray, Tensor]]) – array denoting the true parameter which generated the observation.
labels (Optional[Sequence[str]]) – the string labels for the parameters.
ticks (bool) – whether to show ticks
ticklabels (bool) – whether to show the value of the ticks. only functions when ticks=True.
ticklabelsize (str) – set size of tick labels. see plt.tick_params
tickswhich (str) – whether to affect major or minor ticks. see plt.tick_params
labelrotation (float) – tick label rotation. see plt.tick_params
space_between_axes (float) – changes the wspace and hspace between subplots. see plt.subplots_adjust
- Returns:
matplotlib figure, np array of matplotlib axes
- Return type:
Tuple[Figure, ndarray]
- swyft.plot.plot_empirical_z_score(axes, nominal_z_scores, z_mean, z_interval, mean_color='black', interval_color='0.8', diagonal_color='darkgreen', sigma_color='red', xlim=None, ylim=None, xlabel='Nominal coverage [z-score]', ylabel='Empirical coverage [z-score]', diagonal_text=False)[source]¶
target a particular matplotlib Axes and produce an empirical coverage test plot with Jeffrey’s interval
- Parameters:
axes (Axes) – matplotlib axes
nominal_z_scores (ndarray) – sorted array of nominal z-scores
z_mean (ndarray) – empirical mean of z-score estimate using a binominal distribution
z_interval (ndarray) – jeffrey’s interval of z-score estimate
mean_color (str) – color of the mean line.
interval_color (str) – color of the interval, floats are grey.
diagonal_color (str) – color of the diagonal, nominal z-score.
sigma_color (str) – color of the vertical and horizontal sigma lines.
xlim (Optional[Tuple[float, float]]) – force xlim
ylim (Optional[Tuple[float, float]]) – force ylim
xlabel (Optional[str]) – set xlabel
ylabel (Optional[str]) – set ylabel
diagonal_text (bool) – turns on semantic description of above / below diagonal
- Returns:
the matplotlib axes given
- Return type:
Axes
- swyft.plot.violin(marginals, axes=None, palette='muted', labels=None)[source]¶
create a seaborn violin plot
- Parameters:
marginals (Dict[Tuple[int, ...], Union[ndarray, Tensor]]) – marginals from the estimator, must be samples (NOT weighted samples)
axes (Optional[Axes]) – matplotlib axes
palette (str) – seaborn palette
labels (Optional[Sequence[str]]) – the string labels for the parameters.
- Returns:
Axes
- Return type:
Axes