---
title: draw_layer_errors_swarm (latest version)
description: API reference for qiskit_ibm_runtime.visualization.draw_layer_errors_swarm in the latest version of qiskit-ibm-runtime
source: https://eu-de.quantum.cloud.ibm.com/docs/en/api/qiskit-ibm-runtime/visualization-draw-layer-errors-swarm
---

# qiskit\_ibm\_runtime.visualization.draw\_layer\_errors\_swarm

`draw_layer_errors_swarm(layer_errors, num_bodies=None, max_rate=None, min_rate=None, connected=None, colors=None, num_bins=None, opacities=0.4, names=None, x_coo=None, marker_size=None, height=500, width=800)`

[GitHub](https://github.com/Qiskit/qiskit-ibm-runtime/tree/stable/0.49/qiskit_ibm_runtime/visualization/draw_layer_error.py#L269-L422)

Draw a swarm plot for the given list of layer errors.

This function plots the rates of each of the given layer errors along a vertical axes, offsetting the rates along the `x` axis to minimize the overlap between the markers. It helps visualizing the distribution of errors for different layer errors, as well as to track (using the `connected` argument) the evolution of specific generators across different layers.

> **Note**
>
> To calculate the offsets, this arranges the rates in `num_bins` equally-spaced bins, and then it assigns the `x` coordinates so that all the rates in the same bins are spaced around the vertical axis. Thus, a higher value of `num_bins` will result in higher overlaps between the markers.

**Parameters**

- **layer\_errors** (*list\[*[*LayerError*](/docs/api/qiskit-ibm-runtime/results-layer-error "qiskit_ibm_runtime.results.LayerError")*]*) – The layer errors to draw.
- **num\_bodies** (*int | None*) – The weight of the generators to include in the plot, or `None` if all the generators should be included.
- **max\_rate** (*float | None*) – The largest rate to include in the plot, or `None` if no upper limit should be set.
- **min\_rate** (*float | None*) – The smallest rate to include in the plot, or `None` if no lower limit should be set.
- **connected** (*list\[Pauli | str] | None*) – A list of generators whose markers are to be connected by lines.
- **colors** (*list\[str] | None*) – A list of colors for the markers in the plot, or `None` if these colors are to be chosen automatically.
- **num\_bins** (*int | None*) – The number of bins to place the rates into when calculating the `x`-axis offsets.
- **opacities** (*float | list\[float]*) – A list of opacities for the markers.
- **names** (*list\[str] | None*) – The names of the various layers as displayed in the legend. If `None`, default names are assigned based on the layers’ position inside the `layer_errors` list.
- **x\_coo** (*list\[float] | None*) – The `x`-axis coordinates of the vertical axes that the markers are drawn around, or `None` if these axes should be placed at regular intervals.
- **marker\_size** (*float | None*) – The size of the marker in the plot.
- **height** (*int*) – The height of the returned figure.
- **width** (*int*) – The width of the returned figure.

**Raises**

- **ValueError** – If an invalid grouping option is given.
- **ValueError** – If `colors` is given but its length is incorrect.

**Return type**

PlotlyFigure
