Lifemap.layer_lines
Lifemap.layer_lines(
data=None,
*,
taxid_col='taxid',
width=3,
width_range=(1, 30),
color=None,
scheme=None,
linetype='solid',
opacity=0.8,
popup=True,
popup_col=None,
hover=None,
label=None,
lazy=False,
lazy_zoom=15,
lazy_mode='self',
)Add a lines layer.
This layer can be applied to data 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' |
| width | int | float | str | If numeric, the fixed width of the lines. If a string, the name of a numerical DataFrame column to compute line width from. | 3 |
| width_range | tuple | list | Min and max values for line widths, only used if width is a data column, by default (1, 30) | (1, 30) |
| color | str | None | Either the name of a numerical DataFrame column to determine line color, or a fixed CSS color for lines. | None |
| scheme | str | None | Color scheme for lines color. It is the name of an Observable Plot color scale. | None |
| linetype | Literal['solid', 'dotted', 'smalldash', 'dashed'] | Type of lines. Defaults to ‘solid’. | 'solid' |
| opacity | float | Line 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 color is defined. If None, the value of color 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 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. |
Examples
>>> import polars as pl
>>> from pylifemap import Lifemap, aggregate_num
>>> 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],
... }
... )
>>> d = aggregate_num(d, column="value", fn="mean")
>>> Lifemap(d).layer_lines(width="value", color="value").show()See also
aggregate_num : aggregation of a numeric variable.
aggregate_count : aggregation of the number of observations.