coco_pipe.viz.interactive.base#
General-purpose interactive (Plotly) visualization helpers.
Mirrors the static helpers in coco_pipe.viz.base (plot_bar,
plot_distribution_groups, plot_heatmap) for cases where the report
or notebook wants an interactive figure.
Functions#
|
Interactive ranked bar chart with optional error bars. |
|
Interactive 2D scatter / line-scatter, optionally split into colored groups. |
|
Interactive grouped bar chart ( |
|
Interactive grouped distribution plot (box or violin) with overlaid points. |
|
Interactive 2D heatmap. |
Module Contents#
- coco_pipe.viz.interactive.base.plot_bar(scores, errors=None, labels=None, label_map=None, top_n=None, ascending=False, sort=True, orientation='vertical', color=None, cmap=None, abs_values=False, title=None, xaxis_title=None, yaxis_title=None, height=None)#
Interactive ranked bar chart with optional error bars.
- Parameters:
scores (pandas.Series | collections.abc.Mapping[str, float] | collections.abc.Sequence[float]) – Values to plot. Accepts a
pd.Series,{label: value}mapping, or a plain sequence (thenlabelsis required for tick labels).errors (pandas.Series | collections.abc.Mapping[str, float] | collections.abc.Sequence[float] | None) – Optional symmetric error magnitudes aligned with
scores.labels (collections.abc.Sequence[str] | None) – Tick labels used when
scoresis a plain sequence.label_map (collections.abc.Mapping[str, str] | None) – Optional
{raw_label: display_label}mapping applied to tick labels.top_n (int | None) – Keep only the first
top_nentries after sorting.ascending (bool) – Sort direction when
sort=True.sort (bool) – Whether to sort bars by value before plotting.
orientation (Literal['vertical', 'horizontal']) –
"vertical"(default) or"horizontal".color (str | collections.abc.Sequence[str] | None) – Bar color or per-bar color sequence. Ignored when
cmapis set.cmap (str | None) – Plotly colorscale name used to color bars by value.
abs_values (bool) – Sort and plot by absolute values while preserving the sign for errors.
title (str | None) – Layout labels.
xaxis_title (str | None) – Layout labels.
yaxis_title (str | None) – Layout labels.
height (int | None) – Figure height in pixels.
- Returns:
Interactive bar chart.
- Return type:
plotly.graph_objects.Figure
See also
coco_pipe.viz.base.plot_barStatic Matplotlib version.
plot_distribution_groupsPer-group distribution comparison.
- coco_pipe.viz.interactive.base.plot_scatter(data, x, y, color=None, text=None, hovertemplate=None, mode='markers', sort_x=None, color_map=None, marker_size=8, line_width=2.0, title=None, xaxis_title=None, yaxis_title=None, legend_title=None, height=None)#
Interactive 2D scatter / line-scatter, optionally split into colored groups.
- Parameters:
data (pandas.DataFrame) – Source DataFrame.
x (str) – Column names for the x and y axes.
y (str) – Column names for the x and y axes.
color (str | None) – Optional column name. When given, one trace is drawn per unique value (each gets a legend entry and palette color); otherwise a single trace is drawn.
text (str | None) – Optional column name supplying per-point hover/label text.
hovertemplate (str | None) – Optional Plotly
hovertemplateapplied to every trace.%{text}refers to thetextcolumn.mode (str) – Plotly scatter mode, e.g.
"markers"(default),"lines+markers", or"lines".sort_x (bool | None) – Whether to sort each trace by
xbefore plotting.None(default) auto-enables sorting whenmodecontains"lines"so line segments connect in order.color_map (collections.abc.Mapping[Any, str] | None) – Optional
{group_value: color}overriding palette colors for groups.marker_size (int) – Marker size in pixels.
line_width (float) – Line width for line modes.
title (str | None) – Layout labels. Axis titles default to the
x/ycolumn names.xaxis_title (str | None) – Layout labels. Axis titles default to the
x/ycolumn names.yaxis_title (str | None) – Layout labels. Axis titles default to the
x/ycolumn names.legend_title (str | None) – Optional legend title (typically the
colorcolumn name).height (int | None) – Figure height in pixels.
- Returns:
Interactive scatter figure.
- Return type:
plotly.graph_objects.Figure
See also
plot_barRanked bar chart.
plot_grouped_barGrouped bar chart from a long DataFrame.
- coco_pipe.viz.interactive.base.plot_grouped_bar(data, x, y, group, text=None, text_position='outside', color_map=None, x_order=None, title=None, xaxis_title=None, yaxis_title=None, legend_title=None, height=None)#
Interactive grouped bar chart (
barmode="group") from a long DataFrame.- Parameters:
data (pandas.DataFrame) – Long-format DataFrame: one row per
(x, group)bar.x (str) – Column name for the category axis (shared across groups).
y (str) – Column name for the bar values.
group (str) – Column name defining the bar groups; one trace (legend entry) is drawn per unique value.
text (str | None) – Optional column name supplying per-bar text labels.
text_position (str) – Plotly
textpositionfor bar labels (default"outside").color_map (collections.abc.Mapping[Any, str] | None) – Optional
{group_value: color}overriding palette colors.x_order (collections.abc.Sequence[Any] | None) – Optional explicit ordering for the category axis.
title (str | None) – Layout labels. Axis titles default to the
x/ycolumn names.xaxis_title (str | None) – Layout labels. Axis titles default to the
x/ycolumn names.yaxis_title (str | None) – Layout labels. Axis titles default to the
x/ycolumn names.legend_title (str | None) – Optional legend title (typically the
groupcolumn name).height (int | None) – Figure height in pixels.
- Returns:
Interactive grouped bar chart.
- Return type:
plotly.graph_objects.Figure
See also
plot_barSingle-series ranked bar chart.
plot_scatterScatter / line-scatter from a long DataFrame.
- coco_pipe.viz.interactive.base.plot_distribution_groups(groups, labels, kind='box', show_points=True, point_opacity=0.55, showmeans=True, title=None, xaxis_title=None, yaxis_title=None, color=None, height=None, sig_pairs=None)#
Interactive grouped distribution plot (box or violin) with overlaid points.
- Parameters:
groups (collections.abc.Sequence[collections.abc.Sequence[float] | numpy.ndarray | pandas.Series]) – Sequence of data arrays, one per group. Non-finite values are dropped.
labels (collections.abc.Sequence[Any]) – Group labels aligned with
groups.kind (Literal['box', 'violin']) –
"box"(default) or"violin".show_points (bool) – Overlay individual points on top of each box / violin.
point_opacity (float) – Opacity for overlaid individual points.
showmeans (bool) – Whether to mark the mean inside each box / violin.
title (str | None) – Layout labels.
xaxis_title (str | None) – Layout labels.
yaxis_title (str | None) – Layout labels.
color (str | collections.abc.Sequence[str] | None) – Single color or per-group color list. Defaults to the colorblind palette.
height (int | None) – Figure height in pixels.
sig_pairs (collections.abc.Sequence[tuple[int, int, str]] | None) – Optional sequence of
(idx_a, idx_b, annotation)triples drawing a horizontal significance bracket between groups at indicesidx_aandidx_bwith the given annotation (e.g.,"*","p=0.01").
- Returns:
Interactive distribution figure.
- Return type:
plotly.graph_objects.Figure
See also
coco_pipe.viz.base.plot_distribution_groupsStatic Matplotlib version.
plot_barBar chart with optional error bars.
- coco_pipe.viz.interactive.base.plot_heatmap(matrix, x_labels=None, y_labels=None, cmap=None, center=None, vmin=None, vmax=None, annotate=False, annotation_format='.3g', title=None, xaxis_title=None, yaxis_title=None, colorbar_label=None, height=None)#
Interactive 2D heatmap.
- Parameters:
matrix (pandas.DataFrame | collections.abc.Sequence[collections.abc.Sequence[float]] | numpy.ndarray) – 2D matrix to display. A DataFrame provides default axis labels.
x_labels (collections.abc.Sequence[Any] | None) – Tick labels. Override DataFrame columns / index when provided.
y_labels (collections.abc.Sequence[Any] | None) – Tick labels. Override DataFrame columns / index when provided.
cmap (str | None) – Plotly colorscale. Defaults to
SEQUENTIALunlesscenteris provided, in which caseDIVERGINGis used.center (float | None) – Value mapped to the colormap midpoint (uses
DIVERGING).vmin (float | None) – Explicit colormap bounds.
vmax (float | None) – Explicit colormap bounds.
annotate (bool) – Print values inside cells.
annotation_format (str) – Python format spec for cell annotations.
title (str | None) – Layout labels.
xaxis_title (str | None) – Layout labels.
yaxis_title (str | None) – Layout labels.
colorbar_label (str | None) – Layout labels.
height (int | None) – Figure height in pixels.
- Returns:
Interactive heatmap.
- Return type:
plotly.graph_objects.Figure
See also
coco_pipe.viz.base.plot_heatmapStatic Matplotlib version.
plot_coranking_matrixSquare coranking-matrix heatmap.