viz
Plotting functions
- class scribe.viz.Colors(dark_black=(0.0, 0.0, 0.0), black=(0.0, 0.0, 0.0), light_black=(0.0196078431372549, 0.03137254901960784, 0.058823529411764705), pale_black=(0.12156862745098039, 0.12156862745098039, 0.12156862745098039), dark_blue=(0.1607843137254902, 0.3411764705882353, 0.6588235294117647), blue=(0.2196078431372549, 0.4627450980392157, 0.7529411764705882), light_blue=(0.5058823529411764, 0.6627450980392157, 0.8549019607843137), pale_blue=(0.7529411764705882, 0.8313725490196079, 0.9294117647058824), dark_green=(0.1803921568627451, 0.3607843137254902, 0.0392156862745098), green=(0.27450980392156865, 0.5490196078431373, 0.07058823529411765), light_green=(0.43137254901960786, 0.7372549019607844, 0.1411764705882353), pale_green=(0.6627450980392157, 0.9215686274509803, 0.4392156862745098), dark_red=(0.5686274509803921, 0.1803921568627451, 0.15294117647058825), red=(0.796078431372549, 0.2627450980392157, 0.2196078431372549), light_red=(0.8352941176470589, 0.47843137254901963, 0.4470588235294118), pale_red=(0.9098039215686274, 0.7098039215686275, 0.6901960784313725), dark_gold=(0.7137254901960784, 0.5333333333333333, 0.08627450980392157), gold=(0.9215686274509803, 0.7607843137254902, 0.12156862745098039), light_gold=(0.9490196078431372, 0.8431372549019608, 0.4117647058823529), pale_gold=(0.9686274509803922, 0.9019607843137255, 0.6313725490196078), dark_purple=(0.3686274509803922, 0.19215686274509805, 0.3686274509803922), purple=(0.5764705882352941, 0.30196078431372547, 0.5764705882352941), light_purple=(0.7372549019607844, 0.4980392156862745, 0.7372549019607844), pale_purple=(0.8352941176470589, 0.6862745098039216, 0.8352941176470589))[source]
Bases:
objectPersonal color palette with tab completion support. All colors are RGB tuples on 0-1 scale.
- Parameters:
- light_black: tuple[float, float, float] = (0.0196078431372549, 0.03137254901960784, 0.058823529411764705)
- pale_black: tuple[float, float, float] = (0.12156862745098039, 0.12156862745098039, 0.12156862745098039)
- dark_blue: tuple[float, float, float] = (0.1607843137254902, 0.3411764705882353, 0.6588235294117647)
- light_blue: tuple[float, float, float] = (0.5058823529411764, 0.6627450980392157, 0.8549019607843137)
- pale_blue: tuple[float, float, float] = (0.7529411764705882, 0.8313725490196079, 0.9294117647058824)
- dark_green: tuple[float, float, float] = (0.1803921568627451, 0.3607843137254902, 0.0392156862745098)
- light_green: tuple[float, float, float] = (0.43137254901960786, 0.7372549019607844, 0.1411764705882353)
- pale_green: tuple[float, float, float] = (0.6627450980392157, 0.9215686274509803, 0.4392156862745098)
- dark_red: tuple[float, float, float] = (0.5686274509803921, 0.1803921568627451, 0.15294117647058825)
- light_red: tuple[float, float, float] = (0.8352941176470589, 0.47843137254901963, 0.4470588235294118)
- pale_red: tuple[float, float, float] = (0.9098039215686274, 0.7098039215686275, 0.6901960784313725)
- dark_gold: tuple[float, float, float] = (0.7137254901960784, 0.5333333333333333, 0.08627450980392157)
- light_gold: tuple[float, float, float] = (0.9490196078431372, 0.8431372549019608, 0.4117647058823529)
- pale_gold: tuple[float, float, float] = (0.9686274509803922, 0.9019607843137255, 0.6313725490196078)
- dark_purple: tuple[float, float, float] = (0.3686274509803922, 0.19215686274509805, 0.3686274509803922)
- scribe.viz.plot_posterior(ax, distribution, ground_truth=None, plot_quantiles=(0.001, 0.999), n_points=200, color='blue', ground_truth_color='red', ground_truth_linestyle='--', ground_truth_linewidth=1.5, ground_truth_label=None, alpha=0.6, label=None, fill_between=True, fill_color='blue', fill_alpha=0.2)[source]
Plot a posterior distribution on a given axis.
- Parameters:
ax (matplotlib.axes.Axes) – The axis to plot on
distribution (scipy.stats.rv_continuous) – The distribution to plot
ground_truth (float, optional) – Ground truth value to plot as vertical line
plot_quantiles (tuple of float, optional) – Lower and upper quantiles for plot range (default: (0.001, 0.999))
n_points (int, optional) – Number of points to use for plotting (default: 200)
color (str, optional) – Color for the distribution plot (default: ‘blue’)
ground_truth_color (str, optional) – Color for the ground truth line (default: ‘red’)
ground_truth_linestyle (str, optional) – Line style for ground truth (default: ‘–‘)
ground_truth_linewidth (float, optional) – Line width for ground truth (default: 1.5)
ground_truth_label (str, optional) – Label for the ground truth in the legend
alpha (float, optional) – Transparency for the distribution plot (default: 0.6)
label (str, optional) – Label for the distribution in the legend
fill_between (bool, optional) – Whether to fill the distribution plot (default: True)
fill_color (str, optional) – Color for the fill_between plot (default: ‘blue’)
fill_alpha (float, optional) – Transparency for the fill_between plot (default: 0.2)
- Returns:
The plot is created on the provided axis
- Return type:
None
- scribe.viz.plot_histogram_credible_regions(ax, hist_results, colors=None, cmap=None, alpha=0.2, plot_median=True, median_color='black', median_alpha=0.2, median_linewidth=1.5, label_prefix='', max_bin=None)[source]
Plot credible regions as fill_between on a given axis.
- Parameters:
ax (matplotlib.axes.Axes) – The axis to plot on
hist_results (dict) – Results dictionary from compute_histogram_credible_regions
colors (list, optional) – List of colors for each credible region. Must match length of credible regions. If None and cmap is None, defaults to grays.
cmap (str or matplotlib.colors.Colormap, optional) – Colormap to generate colors from. Ignored if colors is provided.
alpha (float or list, optional) – Transparency for fill_between plots. If float, same alpha used for all regions. If list, must match length of credible regions.
plot_median (bool, optional) – Whether to plot the median line (default: True)
median_color (str, optional) – Color for median line (default: ‘black’)
median_alpha (float, optional) – Transparency for median line (default: 0.8)
median_linewidth (float, optional) – Line width for median line (default: 1.5)
label_prefix (str, optional) – Prefix for legend labels (default: ‘’)
max_bin (int, optional) – Maximum bin index to plot. If provided, only bins up to this index will be shown. Default is None (show all bins).
- Returns:
The axis with plots added
- Return type:
matplotlib.axes.Axes
- scribe.viz.plot_histogram_credible_regions_stairs(ax, hist_results, colors=None, cmap=None, alpha=0.2, plot_median=True, median_color='black', median_alpha=0.2, median_linewidth=1.5, label_prefix='', max_bin=None)[source]
Plot credible regions as fill_between on a given axis.
- Parameters:
ax (matplotlib.axes.Axes) – The axis to plot on
hist_results (dict) – Results dictionary from compute_histogram_credible_regions
colors (list, optional) – List of colors for each credible region. Must match length of credible regions. If None and cmap is None, defaults to grays.
cmap (str or matplotlib.colors.Colormap, optional) – Colormap to generate colors from. Ignored if colors is provided.
alpha (float or list, optional) – Transparency for fill_between plots. If float, same alpha used for all regions. If list, must match length of credible regions.
plot_median (bool, optional) – Whether to plot the median line (default: True)
median_color (str, optional) – Color for median line (default: ‘black’)
median_alpha (float, optional) – Transparency for median line (default: 0.8)
median_linewidth (float, optional) – Line width for median line (default: 1.5)
label_prefix (str, optional) – Prefix for legend labels (default: ‘’)
max_bin (int, optional) – Maximum bin index to plot. If provided, only bins up to this index will be shown. Default is None (show all bins).
- Returns:
The axis with plots added
- Return type:
matplotlib.axes.Axes
- scribe.viz.plot_ecdf_credible_regions_stairs(ax, ecdf_results, colors=None, cmap=None, alpha=0.2, plot_median=True, median_color='black', median_alpha=0.2, median_linewidth=1.5, label_prefix='', max_bin=None)[source]
Plot ECDF credible regions as stairs on a given axis.
- Parameters:
ax (matplotlib.axes.Axes) – The axis to plot on
ecdf_results (dict) – Results dictionary from compute_ecdf_credible_regions
colors (list, optional) – List of colors for each credible region. Must match length of credible regions. If None and cmap is None, defaults to grays.
cmap (str or matplotlib.colors.Colormap, optional) – Colormap to generate colors from. Ignored if colors is provided.
alpha (float or list, optional) – Transparency for fill_between plots. If float, same alpha used for all regions. If list, must match length of credible regions.
plot_median (bool, optional) – Whether to plot the median line (default: True)
median_color (str, optional) – Color for median line (default: ‘black’)
median_alpha (float, optional) – Transparency for median line (default: 0.2)
median_linewidth (float, optional) – Line width for median line (default: 1.5)
label_prefix (str, optional) – Prefix for legend labels (default: ‘’)
max_bin (int, optional) – Maximum x-value index to plot. If provided, only points up to this index will be shown. Default is None (show all points).
- Returns:
The axis with plots added
- Return type:
matplotlib.axes.Axes