Skip to content

feat: create fluxopt-plot companion package #51

@FBumann

Description

@FBumann

Summary

Create a separate fluxopt-plot package that provides interactive plotly-based visualization for Result objects. Depends on fluxopt ~= X.Y, keeps heavy plotting dependencies out of core.

Design

The package monkey-patches a .plot accessor onto Result at import time. All plot methods return a PlotResult(data, figure) for both inspection and customization.

Plot methods

balance(node, *, select, lines, threshold, show, **plotly_kwargs)
carrier_balance(carrier, *, select, unit, threshold, show, **plotly_kwargs)
storage(storage, *, select, unit, charge_state_color, show, **plotly_kwargs)
charge_states(storages, *, select, show, **plotly_kwargs)
flows(*, start, end, component, select, unit, show, **plotly_kwargs)
sizes(*, select, max_size, show, **plotly_kwargs)
duration_curve(variables, *, select, normalize, show, **plotly_kwargs)
heatmap(variables, *, select, reshape, show, **plotly_kwargs)
effects(aspect, *, effect, by, select, show, **plotly_kwargs)
sankey.flows(*, aggregate, select, show, **plotly_kwargs)
sankey.sizes(*, select, show, **plotly_kwargs)
sankey.peak_flow(*, select, show, **plotly_kwargs)
sankey.effects(*, select, show, **plotly_kwargs)

Key features

  • Smart defaults: flows with fixed_profile shown as lines, dispatch as bars
  • lines= override: explicit control over which flows render as lines vs bars
  • Period/scenario handling: periods faceted, scenarios aggregated (mean + band for lines)
  • select= dict: xarray-style filtering (select={"period": "2030"})
  • PlotResult: .data (xr.Dataset), .figure (go.Figure), .show(), .to_html()

Dependencies

[project]
dependencies = ["fluxopt~=X.Y", "plotly>=6.0", "xarray_plotly>=0.0.13"]

Acceptance Criteria

  • Separate PyPI-installable package
  • Monkey-patches .plot onto Result at import time
  • All listed plot methods implemented
  • Every method tested with data_only=True (assert on Dataset)
  • Smoke tests verify figure creation does not raise

Refs

Part of #47 — Architecture: Package Separation, SolutionResult Design, and Stability Tiers

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestvizVisualization and plotting

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions