Lifemap.layer_points

Lifemap.layer_points(
    data=None,
    *,
    taxid_col='taxid',
    leaves='show',
    radius=5,
    radius_range=(2, 30),
    fill=None,
    fill_cat=None,
    categories=None,
    scheme=None,
    opacity=0.8,
    popup=True,
    popup_col=None,
    hover=None,
    label=None,
    lazy=False,
    lazy_zoom=15,
    lazy_mode='self',
)

Add a points layer.

It can be used to display leaves values, or aggregated counts or values already computed or generated by aggregate_num or aggregate_count.

Parameters

Name Type Description Default
data pl.DataFrame | pd.DataFrame | None Layer data. If not provided, use the base widget data. None
taxid_col str If data is provided, name of the data column with taxonomy ids, by default "taxid" 'taxid'
leaves Literal["show", "only", "omit"] If "only", only show tree leaves. If "omit", only show nodes that are not leaves. If "show", show all nodes, by default “show” 'show'
radius int | float | str If numeric, the fixed radius of the points. If a string, the name of a numerical DataFrame column to compute radius width from. 5
radius_range tuple | list Range of values for points radius, only used if radius_col is not None, by default (2, 30) (2, 30)
fill str | None Either the name of a numerical DataFrame column to determine points color, or a fixed CSS color for points. None
fill_cat bool | None If True, force color scheme to be categorical. If False, force it to be continuous. If None, let pylifemap decide. By default None. None
categories list | tuple | None Custom order of categories when a categorical variable is used for the fill argument. Defaults to None. None
scheme str | None Color scheme for points color. It is the name of an Observable Plot color scale. None
opacity float Points opacity as a floating number between 0 and 1, by default 0.8 0.8
popup bool If True, display informations in a popup when a point is clicked, by default True True
popup_col str | None Name of a data column containing custom popup content. By default None. None
hover bool | None If True, highlight points on mouse hovering. By default True if less than 10_000 data points, False otherwise. None
label str | None Legend title for this layer if fill is defined. If None, the value of fill is used. None
lazy bool If True, points are displayed depending on the widget view. If False, all points are displayed. Can be useful when displaying a great number of items. Defaults to False. False
lazy_zoom int If lazy is True, only points with a zoom level less than (zoom + lazy_zoom) level will be displayed. Defaults to 15. 15
lazy_mode Literal['self', 'parent'] If lazy is True, choose the zoom level to apply to each taxa. If “self”, keep the taxa zoom level. If “parent”, get the nearest ancestor zoom level. Defaults to “self”. 'self'

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
>>> d = pl.DataFrame(
...     {
...         "taxid": [
...             9685,
...             9615,
...             9994,
...             2467430,
...             2514524,
...             2038938,
...             1021470,
...             1415565,
...             1928562,
...             1397240,
...             230741,
...         ],
...         "value": [7.4, 2.5, 8.3, 1.0, 1.4, 5.6, 4.6, 3.4, 2.3, 2.8, 3.1],
...     }
... )
>>> Lifemap(d).layer_points(radius="value", fill="value", popup=True).show()

See also

aggregate_num : aggregation of a numeric variable.

aggregate_count : aggregation of the number of observations.