proteobench.plotting.utils package#
Building blocks of the plot generators.
plotly_helpers holds the small helpers every generator needs. The other modules each hold
one figure that is too large to keep inside a generator class: the generator declares the plot
and forwards to the module, which owns the computation and the layout.
- proteobench.plotting.utils.create_kde_distribution_plot(hist_data: Sequence[Sequence[float]], group_labels: Sequence[str], colors: Sequence[str]) Figure[source]#
Plot one kernel density curve per group.
Reproduces
plotly.figure_factory.create_distplot(..., show_hist=False, show_rug=False), which was removed in plotly 7.0.0. Each curve is a Gaussian KDE evaluated on aKDE_POINTS-point grid spanning that group’s own minimum to maximum, matching the grid and default bandwidth the figure factory used, so existing figures are unchanged.Groups with fewer than two distinct values are skipped: a KDE needs a non-zero spread and would otherwise raise inside
gaussian_kde.- Parameters:
hist_data (Sequence[Sequence[float]]) – One sequence of observations per group.
group_labels (Sequence[str]) – Trace name for each group, in the same order as
hist_data.colors (Sequence[str]) – Colour for each group. Indexed cyclically, as the figure factory did, so a short sequence repeats rather than raising.
- Returns:
Figure with one filled line trace per plottable group.
- Return type:
go.Figure
- proteobench.plotting.utils.empty_figure(message: str) Figure[source]#
Build a placeholder figure carrying an explanatory annotation.
Used by plots that cannot be drawn because their input is missing or insufficient, so the web interface shows the reason instead of an empty plot area.
- Parameters:
message (str) – Text shown in the center of the empty plot area.
- Returns:
A figure with no traces and a centered annotation.
- Return type:
go.Figure
- proteobench.plotting.utils.fill_density_traces(fig: Figure, opacity: float = 0.4) Figure[source]#
Shade the area under each line trace.
- Parameters:
fig (go.Figure) – Figure whose line traces should be filled, modified in place.
opacity (float) – Opacity of the shaded area.
- Returns:
The same figure, for chaining.
- Return type:
go.Figure
- proteobench.plotting.utils.hex_to_rgba(color: str, alpha: float) str[source]#
Convert a hex color string to an
rgba(...)string with the given opacity.