coco_pipe.viz.interactive.base ============================== .. py:module:: coco_pipe.viz.interactive.base .. autoapi-nested-parse:: General-purpose interactive (Plotly) visualization helpers. Mirrors the static helpers in :mod:`coco_pipe.viz.base` (``plot_bar``, ``plot_distribution_groups``, ``plot_heatmap``) for cases where the report or notebook wants an interactive figure. Functions --------- .. autoapisummary:: coco_pipe.viz.interactive.base.plot_bar coco_pipe.viz.interactive.base.plot_scatter coco_pipe.viz.interactive.base.plot_grouped_bar coco_pipe.viz.interactive.base.plot_distribution_groups coco_pipe.viz.interactive.base.plot_heatmap Module Contents --------------- .. py:function:: 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. :param scores: Values to plot. Accepts a ``pd.Series``, ``{label: value}`` mapping, or a plain sequence (then ``labels`` is required for tick labels). :param errors: Optional symmetric error magnitudes aligned with ``scores``. :param labels: Tick labels used when ``scores`` is a plain sequence. :param label_map: Optional ``{raw_label: display_label}`` mapping applied to tick labels. :param top_n: Keep only the first ``top_n`` entries after sorting. :param ascending: Sort direction when ``sort=True``. :param sort: Whether to sort bars by value before plotting. :param orientation: ``"vertical"`` (default) or ``"horizontal"``. :param color: Bar color or per-bar color sequence. Ignored when ``cmap`` is set. :param cmap: Plotly colorscale name used to color bars by value. :param abs_values: Sort and plot by absolute values while preserving the sign for errors. :param title: Layout labels. :param xaxis_title: Layout labels. :param yaxis_title: Layout labels. :param height: Figure height in pixels. :returns: Interactive bar chart. :rtype: plotly.graph_objects.Figure .. seealso:: :py:obj:`coco_pipe.viz.base.plot_bar` Static Matplotlib version. :py:obj:`plot_distribution_groups` Per-group distribution comparison. .. py:function:: 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. :param data: Source DataFrame. :param x: Column names for the x and y axes. :param y: Column names for the x and y axes. :param color: 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. :param text: Optional column name supplying per-point hover/label text. :param hovertemplate: Optional Plotly ``hovertemplate`` applied to every trace. ``%{text}`` refers to the ``text`` column. :param mode: Plotly scatter mode, e.g. ``"markers"`` (default), ``"lines+markers"``, or ``"lines"``. :param sort_x: Whether to sort each trace by ``x`` before plotting. ``None`` (default) auto-enables sorting when ``mode`` contains ``"lines"`` so line segments connect in order. :param color_map: Optional ``{group_value: color}`` overriding palette colors for groups. :param marker_size: Marker size in pixels. :param line_width: Line width for line modes. :param title: Layout labels. Axis titles default to the ``x`` / ``y`` column names. :param xaxis_title: Layout labels. Axis titles default to the ``x`` / ``y`` column names. :param yaxis_title: Layout labels. Axis titles default to the ``x`` / ``y`` column names. :param legend_title: Optional legend title (typically the ``color`` column name). :param height: Figure height in pixels. :returns: Interactive scatter figure. :rtype: plotly.graph_objects.Figure .. seealso:: :py:obj:`plot_bar` Ranked bar chart. :py:obj:`plot_grouped_bar` Grouped bar chart from a long DataFrame. .. py:function:: 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. :param data: Long-format DataFrame: one row per ``(x, group)`` bar. :param x: Column name for the category axis (shared across groups). :param y: Column name for the bar values. :param group: Column name defining the bar groups; one trace (legend entry) is drawn per unique value. :param text: Optional column name supplying per-bar text labels. :param text_position: Plotly ``textposition`` for bar labels (default ``"outside"``). :param color_map: Optional ``{group_value: color}`` overriding palette colors. :param x_order: Optional explicit ordering for the category axis. :param title: Layout labels. Axis titles default to the ``x`` / ``y`` column names. :param xaxis_title: Layout labels. Axis titles default to the ``x`` / ``y`` column names. :param yaxis_title: Layout labels. Axis titles default to the ``x`` / ``y`` column names. :param legend_title: Optional legend title (typically the ``group`` column name). :param height: Figure height in pixels. :returns: Interactive grouped bar chart. :rtype: plotly.graph_objects.Figure .. seealso:: :py:obj:`plot_bar` Single-series ranked bar chart. :py:obj:`plot_scatter` Scatter / line-scatter from a long DataFrame. .. py:function:: 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. :param groups: Sequence of data arrays, one per group. Non-finite values are dropped. :param labels: Group labels aligned with ``groups``. :param kind: ``"box"`` (default) or ``"violin"``. :param show_points: Overlay individual points on top of each box / violin. :param point_opacity: Opacity for overlaid individual points. :param showmeans: Whether to mark the mean inside each box / violin. :param title: Layout labels. :param xaxis_title: Layout labels. :param yaxis_title: Layout labels. :param color: Single color or per-group color list. Defaults to the colorblind palette. :param height: Figure height in pixels. :param sig_pairs: Optional sequence of ``(idx_a, idx_b, annotation)`` triples drawing a horizontal significance bracket between groups at indices ``idx_a`` and ``idx_b`` with the given annotation (e.g., ``"*"``, ``"p=0.01"``). :returns: Interactive distribution figure. :rtype: plotly.graph_objects.Figure .. seealso:: :py:obj:`coco_pipe.viz.base.plot_distribution_groups` Static Matplotlib version. :py:obj:`plot_bar` Bar chart with optional error bars. .. py:function:: 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. :param matrix: 2D matrix to display. A DataFrame provides default axis labels. :param x_labels: Tick labels. Override DataFrame columns / index when provided. :param y_labels: Tick labels. Override DataFrame columns / index when provided. :param cmap: Plotly colorscale. Defaults to ``SEQUENTIAL`` unless ``center`` is provided, in which case ``DIVERGING`` is used. :param center: Value mapped to the colormap midpoint (uses ``DIVERGING``). :param vmin: Explicit colormap bounds. :param vmax: Explicit colormap bounds. :param annotate: Print values inside cells. :param annotation_format: Python format spec for cell annotations. :param title: Layout labels. :param xaxis_title: Layout labels. :param yaxis_title: Layout labels. :param colorbar_label: Layout labels. :param height: Figure height in pixels. :returns: Interactive heatmap. :rtype: plotly.graph_objects.Figure .. seealso:: :py:obj:`coco_pipe.viz.base.plot_heatmap` Static Matplotlib version. :py:obj:`plot_coranking_matrix` Square coranking-matrix heatmap.