Donuts layer

The donuts layer displays aggregated levels count of a categorical variable as donut charts, optionally displayng the individual values with points.

import polars as pl
from pylifemap import Lifemap, aggregate_freq

# Load iucn dataset
iucn = pl.read_parquet(
    "https://raw.githubusercontent.com/Lifemap-ToL/pylifemap/main/data/iucn.parquet"
)

# Aggregate observations count along branches
iucn_freq = aggregate_freq(iucn, column="status")

(
    Lifemap(iucn_freq)
    .layer_donuts(counts_col="status", opacity=0.9, leaves="show")
    .show()
)
Warning: 787 taxids have not been found in Lifemap database.
Warning: 9976 duplicated taxids have been found in the data.

The leaves argument allows to "show" or "hide" individual leaves values.

The radius argument allows to modify the size of each donut chart. If it is a single integer, the size will be fixed. If it is an Array of two integers, the size will vary depending on the total count of the variable for this node. In the following example we make the size vary between 40 and 150, and we also show the total count as a number with the show_totals argument.

(
    Lifemap(iucn_freq)
    .layer_donuts(counts_col="status", radius = [40, 150], show_totals = True)
    .show()
)

For a detailed list of layer_donuts arguments you can take a look at its documentation.