kopia lustrzana https://github.com/anitagraser/ogd-at-lab
Add linked selections example
rodzic
772ac602fe
commit
89bd009ff2
|
@ -92,7 +92,63 @@
|
|||
"outputs": [],
|
||||
"source": [
|
||||
"col = 'airtemp °C'\n",
|
||||
"stations.join(air_quality).dropna(subset=[col]).hvplot(geo=True, tiles='StamenToner', c=col, size=500, title=col.title())"
|
||||
"stations = stations.join(air_quality).dropna(subset=[col])"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"stations.hvplot(geo=True, tiles='StamenToner', c=col, size=500, title=col.title())"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from holoviews.selection import link_selections"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"my_map = stations.hvplot(geo=True, tiles='CartoLight', c=col, cmap='Viridis', size=200, title=col.title(), width=400, height=250)\n",
|
||||
"my_scatter = pd.DataFrame(stations).hvplot.scatter(x='airtemp °C', y='windspeed kmh', width=250, height=250)\n",
|
||||
"my_hist = pd.DataFrame(stations).hvplot.hist('airtemp °C', width=250, height=250)\n",
|
||||
"link_selections(my_map + my_hist + my_scatter , index_cols=['id'])"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import panel as pn"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"def my_plot(my_col='airtemp °C'):\n",
|
||||
" try: \n",
|
||||
" my_map = stations.hvplot(geo=True, tiles='CartoLight', c=my_col, cmap='Viridis', size=200, title=my_col, width=400, height=250)\n",
|
||||
" my_hist = pd.DataFrame(stations).hvplot.hist(my_col, title=my_col, width=250, height=250)\n",
|
||||
" return link_selections(my_map + my_hist, index_cols=['id']) \n",
|
||||
" except:\n",
|
||||
" pass\n",
|
||||
"kw = dict(my_col=air_quality.columns)\n",
|
||||
"pn.interact(my_plot, **kw)"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -105,7 +161,7 @@
|
|||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"display_name": "Python 3 (ipykernel)",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
|
@ -119,7 +175,7 @@
|
|||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.7.8"
|
||||
"version": "3.7.15"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
|
|
Ładowanie…
Reference in New Issue