Skip to main content
Ctrl+K
HoloViews v1.20.2 - Home HoloViews v1.20.2 - Home
  • Getting Started
  • User Guide
  • Gallery
  • Reference Gallery
  • Developer Guide
    • Releases
    • API
    • FAQ Roadmap
    • About
  • GitHub
  • Twitter
  • Discourse
  • Discord
  • Getting Started
  • User Guide
  • Gallery
  • Reference Gallery
  • Developer Guide
  • Releases
  • API
  • FAQ Roadmap
  • About
  • GitHub
  • Twitter
  • Discourse
  • Discord
  • Getting Started
    • Introduction
    • Customization
    • Tabular Datasets
    • Gridded Datasets
    • Live Data
  • User Guide
    • Annotating your Data
    • Composing Elements
    • Applying Customizations
    • Style Mapping
    • Dimensioned Containers
    • Building Composite Objects
    • Live Data
    • Tabular Datasets
    • Gridded Datasets
    • Geometry Data
    • Indexing and Selecting Data
    • Transforming Elements
    • Responding to Events
    • Custom Interactivity
    • Data Processing Pipelines
    • Creating interactive network graphs
    • Working with large data
    • Working with streaming data
    • Creating interactive dashboards
    • Customizing Plots
    • Colormaps
    • Plotting with Bokeh
    • Deploying Bokeh Apps
    • Linking Bokeh plots
    • Plotting with matplotlib
    • Working with Plot and Renderers
    • Linked Brushing
    • Annotators
    • Exporting and Archiving
    • Continuous Coordinates
    • Notebook Magics
  • Gallery
    • Applications
      • Bokeh
        • Crossfilter
        • Game Of Life
        • Gapminder
        • Mandelbrot
        • Nytaxi Hover
        • Streaming Psutil
    • Demos
      • Bokeh
        • Area Chart
        • Autompg Histogram
        • Autompg Violins
        • Bachelors Degrees By Gender
        • Bars Economic
        • Box Draw Roi Editor
        • Boxplot Chart
        • Choropleth Data Link
        • Directed Airline Routes
        • Dot Example
        • Dragon Curve
        • Dropdown Economic
        • Emoji Tsne
        • Energy Sankey
        • Hextile Movie Ratings
        • Histogram Example
        • Html Hover Tooltips
        • Image Range Tool
        • Iris Density Grid
        • Iris Example
        • Iris Grouped Grid
        • Iris Splom Example
        • Irregular Quadmesh
        • Legend Example
        • Lesmis Example
        • Life Expectancy Split Violin
        • Lorenz Attractor Example
        • Mandelbrot Section
        • Measles Example
        • Multichannel Timeseries Viewer
        • Network Graph
        • Nyc Airport Connections
        • Nyc Radial Heatmap
        • Point Draw Triangulate
        • Quiver Demo
        • Route Chord
        • Scatter Economic
        • Square Limit
        • Step Chart
        • Stocks Example
        • Texas Choropleth Example
        • Timeseries Range Tool
        • Topographic Hillshading
        • Us Unemployment
        • Verhulst Mandelbrot
  • Reference Gallery
    • Elements
      • Bokeh
        • Area
        • Arrow
        • Bars
        • Bivariate
        • Bounds
        • Box
        • BoxWhisker
        • Chord
        • Contours
        • Curve
        • Distribution
        • Div
        • Ellipse
        • ErrorBars
        • Graph
        • HLine
        • HLines
        • HSV
        • HSpan
        • HSpans
        • HeatMap
        • HexTiles
        • Histogram
        • Image
        • ImageStack
        • ItemTable
        • Labels
        • Path
        • Points
        • Polygons
        • QuadMesh
        • RGB
        • RadialHeatMap
        • Raster
        • Rectangles
        • Sankey
        • Scatter
        • Segments
        • Slope
        • Spikes
        • Spline
        • Spread
        • Table
        • Text
        • Tiles
        • TriMesh
        • VLine
        • VLines
        • VSpan
        • VSpans
        • VectorField
        • Violin
      • Matplotlib
        • Area
        • Arrow
        • Bars
        • Bivariate
        • Bounds
        • Box
        • BoxWhisker
        • Chord
        • Contours
        • Curve
        • Distribution
        • Ellipse
        • ErrorBars
        • Graph
        • HLine
        • HLines
        • HSV
        • HSpan
        • HSpans
        • HeatMap
        • HexTiles
        • Histogram
        • Image
        • ImageStack
        • ItemTable
        • Labels
        • Path
        • Path3D
        • Points
        • Polygons
        • QuadMesh
        • RGB
        • RadialHeatMap
        • Raster
        • Rectangles
        • Sankey
        • Scatter
        • Scatter3D
        • Segments
        • Slope
        • Spikes
        • Spline
        • Spread
        • Surface
        • Table
        • Text
        • TriMesh
        • TriSurface
        • VLine
        • VLines
        • VSpan
        • VSpans
        • VectorField
        • Violin
      • Plotly
        • Area
        • Bars
        • Bounds
        • Box
        • BoxWhisker
        • Curve
        • Distribution
        • Ellipse
        • ErrorBars
        • HLine
        • HSpan
        • HeatMap
        • Histogram
        • Image
        • ImageStack
        • ItemTable
        • Path3D
        • Points
        • RGB
        • Raster
        • Scatter
        • Scatter3D
        • Spread
        • Surface
        • Table
        • Tiles
        • TriSurface
        • VLine
        • VSpan
        • Violin
    • Containers
      • Bokeh
        • DynamicMap
        • GridSpace
        • HoloMap
        • Layout
        • NdLayout
        • NdOverlay
        • Overlay
      • Matplotlib
        • DynamicMap
        • GridSpace
        • HoloMap
        • Layout
        • NdLayout
        • NdOverlay
        • Overlay
      • Plotly
        • DynamicMap
        • GridSpace
        • HoloMap
        • Layout
        • NdLayout
        • NdOverlay
        • Overlay
    • Streams
      • Bokeh
        • Bounds
        • BoundsX
        • BoundsY
        • BoxEdit
        • CurveEdit
        • FreehandDraw
        • PointDraw
        • PointerX
        • PointerXY
        • PolyDraw
        • PolyEdit
        • RangeXY
        • Selection1D
        • Selection1D Paired
        • Selection1D Points
        • Selection1D Tap
        • Tap
      • Plotly
        • Bounds
        • BoundsX
        • BoundsY
        • RangeXY
        • Selection1D Paired
        • Selection1D Points
    • Apps
      • Bokeh
        • Player
        • Selection Stream
        • Sine
    • Features
      • Bokeh
        • Scalebar
  • Developer Guide
  • Releases
  • API
    • annotators
    • core
      • holoviews.data Package
    • core.data
    • element
    • ipython
    • operation
    • plotting
      • holoviews.bokeh Package
      • holoviews.mpl Package
      • holoviews.plotly Package
    • plotting.bokeh
    • plotting.plotly
    • selection
    • streams
    • util
  • FAQ Roadmap
  • About
HoloViz.org
  • Panel
  • hvPlot
  • GeoViews
  • Datashader
  • Param
  • Lumen
  • Colorcet

  • Examples Gallery
  • Blog
  • Gallery
  • Demos
  • Bokeh
  • Choropleth Data Link

Choropleth Data Link#

Download this notebook from GitHub (right-click to download).


import holoviews as hv
from holoviews import opts

from holoviews.plotting.links import DataLink

hv.extension('bokeh')

This example demonstrates how to use a DataLink to join two elements displaying the same data, a choropleth of the Texas unemployment rate alongside a Table of the same data. By linking the two selecting a polygon will highlight it in the table and vice versa.

Declare data#

from bokeh.sampledata.us_counties import data as counties
from bokeh.sampledata.unemployment import data as unemployment

counties = [dict(county, Unemployment=unemployment[cid])
            for cid, county in counties.items()
            if county["state"] == "tx"]


county_data = [(county['detailed_name'], county['Unemployment']) for county in counties]

choropleth = hv.Polygons(counties, ['lons', 'lats'], [('detailed_name', 'County'), 'Unemployment'], label='Texas Unemployment')
table = hv.Table(county_data, [('detailed_name', 'County'), 'Unemployment'])

print(len(choropleth.data), len(table))
254 254

Declare Plot#

As shown above the two elements have the same length meaning that they can be linked. Linking the data in this way allows cross-selecting, e.g. by selecting one or more rows in the Table we can see the polygon for the county highlight in the choropleth:

# Link the choropleth and the table
DataLink(choropleth, table)

(choropleth + table).opts(
    opts.Table(height=428),
    opts.Polygons(width=500, height=500,  tools=['hover', 'tap'], xaxis=None, 
                  yaxis=None, color_index='Unemployment'))
WARNING:param.PolygonPlot: The `color_index` parameter is deprecated in favor of color style mapping, e.g. `color=dim('color')` or `line_color=dim('color')`
This web page was generated from a Jupyter notebook and not all interactivity will work on this website. Right click to download and run locally for full Python-backed interactivity.

Download this notebook from GitHub (right-click to download).

previous

Boxplot Chart

next

Directed Airline Routes

On this page
  • Declare data
  • Declare Plot

This Page

  • Show Source

© Copyright 2005 HoloViz developers.

Created using Sphinx 8.2.3.

Built with the PyData Sphinx Theme 0.16.1.

OSZAR »