{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "URL: https://docs.bokeh.org/en/latest/docs/examples/topics/geo/texas_hover_map.html\n", "\n", "Most examples work across multiple plotting backends, this example is also available for:\n", "\n", "* [Matplotlib - texas choropleth example](../matplotlib/texas_choropleth_example.ipynb)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import holoviews as hv\n", "from holoviews import opts\n", "hv.extension('bokeh')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Declaring data" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from bokeh.sampledata.us_counties import data as counties\n", "from bokeh.sampledata.unemployment import data as unemployment\n", "\n", "counties = [dict(county, Unemployment=unemployment[cid])\n", " for cid, county in counties.items()\n", " if county[\"state\"] == \"tx\"]\n", "\n", "detailed_name = 'detailed_name' if counties[0].get('detailed_name') else 'detailed name' # detailed name was changed in Bokeh 3.0\n", "choropleth = hv.Polygons(counties, ['lons', 'lats'], [(detailed_name, 'County'), 'Unemployment'])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Plot" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "choropleth.opts(\n", " opts.Polygons(logz=True, tools=['hover'], xaxis=None, yaxis=None,\n", " show_grid=False, show_frame=False, width=500, height=500,\n", " color_index='Unemployment', colorbar=True, toolbar='above', line_color='white'))" ] } ], "metadata": { "language_info": { "name": "python", "pygments_lexer": "ipython3" } }, "nbformat": 4, "nbformat_minor": 4 }