Lifemap.layer_donuts
Lifemap.layer_donuts(
counts_col,
*,
radius=None,
leaves='hide',
scheme=None,
opacity=1,
popup=True,
label=None,
)Add a donuts layer.
This layer displays the distribution of a categorical variable values among each nodes children. Optionally it can also represent leaves values as a point layer.
It should be applied to data computed with aggregate_freq.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| counts_col | str | DataFrame column containing the counts. | required |
| radius | float | None | Donut charts radius, by default None | None |
| leaves | Literal["show", "hide"] | If "show", add a points layer with individual leaves values, by default “hide” |
'hide' |
| scheme | str | None | Color scheme for donut charts ans points. It is the name of a categorical Observable Plot color scale, by default None | None |
| opacity | float | None | Donut charts and points opacity, by default 1 | 1 |
| popup | bool | None | If True, display informations in a popup when a point is clicked, by default False, by default True | True |
| label | str | None | Legend title for this layer. If None, the value of counts_col is used. |
None |
Returns
| Name | Type | Description |
|---|---|---|
| Lifemap | A Lifemap visualization object. |
Raises
| Name | Type | Description |
|---|---|---|
| ValueError | If leaves is not one of the allowed values. |
Examples
>>> import polars as pl
>>> from pylifemap import Lifemap, aggregate_freq
>>> d = pl.DataFrame(
... {
... "taxid": [
... 9685,
... 9615,
... 9994,
... 2467430,
... 2514524,
... 2038938,
... 1021470,
... 1415565,
... 1928562,
... 1397240,
... 230741,
... ],
... "category": ["a", "b", "b", "a", "a", "c", "a", "b", "b", "a", "b"],
... }
... )
>>> d = aggregate_freq(d, column="category")
>>> Lifemap(d).layer_donuts(counts_col="category", leaves="hide").show()See also
: aggregation of the values counts of a categorical variable.