Lifemap.layer_icons
Lifemap.layer_icons(
data=None,
*,
taxid_col='taxid',
icon,
width=None,
height=None,
scale=None,
color=None,
x_offset=0,
y_offset=0,
x_anchor=0.5,
y_anchor=0.5,
opacity=1.0,
popup=True,
popup_col=None,
declutter=True,
lazy=False,
lazy_zoom=10,
lazy_mode='self',
)Add an icons layer.
It can be used to display icons associated to taxids.
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' |
| icon | str | Either the URL to an image file or data uri to use as icon, or the name of a column of the data containing urls or data uris of icons to be displayed. | required |
| width | int | None | Image width, in pixels. | None |
| height | int | None | Image height, in pixels. | None |
| scale | float | None | Factor with which to scale the original icon size. Cannot be used with width or height. | None |
| color | str | None | CSS color to tint the icon, by default None. | None |
| x_offset | int | Horizontal offset in pixels, by default 0. | 0 |
| y_offset | int | Vertical offset in pixels, by default 0. | 0 |
| x_anchor | float | Horizontal icon anchor, as a number between 0 and 1, by default 0.5. | 0.5 |
| y_anchor | float | Vertical icon anchor, as a number between 0 and 1, by default 0.5. | 0.5 |
| opacity | float | Text opacity as a floating number between 0 and 1, by default 1.0. | 1.0 |
| popup | bool | If True, display informations in a popup when an icon is clicked, by default True. | True |
| popup_col | str | None | Name of a data column containing custom popup content. By default None. | None |
| declutter | bool | If True, use OpenLayers decluttering option for this layer. Defaults to True. | True |
| 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 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,
... ]
... }
... )
>>> Lifemap(d).layer_icons(icon="https://openlayers.org/en/latest/examples/data/icon.png").show()