Lifemap.layer_arcs
Lifemap.layer_arcs(
data=None,
*,
taxid_col='taxid',
taxid_dest_col,
width=3,
width_range=(1, 10),
color=None,
color_cat=None,
categories=None,
scheme=None,
linetype='solid',
arrow=False,
arrow_width=9,
arrow_width_range=(7, 20),
opacity=1.0,
popup=True,
popup_col=None,
hover=None,
label=None,
lazy=None,
lazy_zoom=10,
lazy_mode='self',
)Add an arcs layer.
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 | Name of the data column with arc start taxonomy ids. By default 'taxid'. |
'taxid' |
| taxid_dest_col | str | Name of the data column with arc end taxonomy ids. | required |
| width | int | float | str | If numeric, the fixed width of the arcs. If a string, the name of a numerical DataFrame column to compute arc width from. | 3 |
| width_range | tuple | list | Min and max values for arcs widths, only used if width is a data column. By default (1, 30). |
(1, 10) |
| color | str | None | Either the name of a numerical DataFrame column to determine arc color, or a fixed CSS color for arcs. | None |
| color_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 | Sequence | None | Custom order of categories when a categorical variable is used for the color argument. Defaults to None. |
None |
| scheme | str | None | Color scheme for arcs color. It is the name of an Observable Plot color scale. | None |
| linetype | Literal['solid', 'dotted', 'smalldash', 'dashed'] | Type of arcs. Defaults to 'solid'. |
'solid' |
| arrow | bool | If True, add an arrow head to the destination point. By default false. | False |
| arrow_width | int | Width of arrow heads if arrow is True and width is not a data column. By default 9. | 9 |
| width_range | tuple | list | Min and max values for arrow heads widths, only used if width is a data column. By default (8, 20). |
(1, 10) |
| opacity | float | Arc opacity as a floating number between 0 and 1. By default 1. | 1.0 |
| 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 color is defined. If None, the value of color is used. |
None |
| lazy | bool | None | 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 None. |
None |
| lazy_zoom | int | If lazy is True, only arcs with a zoom level less than (current zoom + lazy_zoom) level will be displayed. Defaults to 10. |
10 |
| 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. |
Examples
>>> import polars as pl
>>> from pylifemap import Lifemap
>>> d = pl.DataFrame(
... {
... "taxid": [
... 9685,
... 9615,
... 9994,
... 2467430,
... 2514524,
... 2038938,
... 1021470,
... 1415565,
... 1928562,
... 1397240,
... 230741,
... ],
... "dest_taxid": [
... 9615,
... 1415565,
... 2467430,
... 9994,
... 9685,
... 2514524,
... 2038938,
... 1397240,
... 1021470,
... 1928562,
... 230741,
... ],
... "relation": ["A", "A", "B", "C", "A", "A", "B", "C", "B", "A", "A"],
... }
... )
Lifemap(d).layer_arcs(taxid_dest_col="dest_taxid", color="relation", arrow=True).show()