# scope_profiler.plotting_scripts.imbalance

*module*

Rank-imbalance plots: per-region duration spread across ranks.

[View source](https://github.com/max-models/scope-profiler/blob/devel/src/scope_profiler/plotting_scripts/imbalance.py#L1-L1)

## scope_profiler.plotting_scripts.imbalance.plot_imbalance

*function*

```python
def plot_imbalance(profiling_data: ProfilingResults | Sequence[ProfilingResults], metric: str = 'total', ranks: list[int] | int | None = None, include: list[str] | str | None = None, exclude: list[str] | str | None = None, filepath: str | None = None, show: bool = False, verbose: bool = True, cmap: str = DEFAULT_CMAP, log_scale: bool = False, data_filepath: str | Path | None = None, data_format: str = 'csv', backend: str = 'matplotlib') -> None
```

Plot each region's duration statistic per rank, to surface load imbalance.

One point per (region, rank), connected by a line in rank order, with a
dashed horizontal line at the mean over ranks - so a straggler rank shows
up as a point sitting well off its region's line. This is a per-rank view
of the same statistics :func:`plot_durations` aggregates across ranks.

Parameters
----------
metric : str
    Which per-call duration statistic to plot per rank; one of
    ``"avg"``, ``"min"``, ``"max"``, ``"total"`` (default: ``"total"``,
    the total time a rank spent in the region).
backend : str
    Backend to use for rendering: "matplotlib" (default) or "plotly".

[View source](https://github.com/max-models/scope-profiler/blob/devel/src/scope_profiler/plotting_scripts/imbalance.py#L27-L222)
