Skip to content

Maps

Datapane supports all major Python visualization libraries, allowing you to add interactive maps to your app.

The dp.Plot block takes a plot object from one of the supported Python visualisation libraries and renders it in your app.

Info

Datapane will automatically wrap your visualization in a dp.Plot block if you pass it into your app directly.

It takes the following parameters:

  • name: Sets the name of the chart within the caption
  • caption : Adds a caption beneath your plot
  • responsive: Boolean (True by default) which controls whether the plot fills the block. Set to False if you want to manually specify the height and width within the plot object.
dp.Plot(
    fig, name="fig1", caption="Chart showing average life expectancy", responsive=False
)

Datapane currently supports the following libraries for mapping geographical data:

Library Site / Docs
Folium https://python-visualization.github.io/folium/
Altair https://altair-viz.github.io/
Matplotlib / Seaborn https://matplotlib.org/ / https://seaborn.pydata.org/
Bokeh https://bokeh.org/
Plotly https://plotly.com/python/

If you're using another visualization library e.g. Pyvis for networks, try saving your chart as a local HTML file and wrapping that in a dp.HTML block.

Folium

Folium makes it easy to visualize data that’s been manipulated in Python on an interactive leaflet map. It enables both the binding of data to a map for choropleth visualizations as well as passing rich vector/raster/HTML visualizations as markers on the map.

The library has a number of built-in tilesets from OpenStreetMap, Mapbox, and Stamen, and supports custom tilesets with Mapbox or Cloudmade API keys.

Info

If your folium map consumes live data which expires after a certain time, you can automate it to refresh the map on a cadence. See Automation.

import folium
import datapane as dp

m = folium.Map(location=[45.5236, -122.6750])

dp.App(dp.Plot(m)).save(path="folium-plot.html")