0

I have a dash and plotly application, with a figure like the following (adapting the examples in this tutorial:

enter image description here

I would like, when I put my mouse over a county, to see a plot on top of the US plot with some information of the county. For instance, if I have the historic values of the unemployment rate I would like to see the time series plotted on top of the map, in a little figure that allows me to still see the map.

Is there an easy way of doing this using dash and plotly? Thanks!

1 Answer 1

1

To my knowledge, it is not (yet) possible to embed graphs in the tooltips with mapbox. If you are not restricted to using mapbox, you could do it with Dash Leaflet, which supports more advanced tool tips including graphs. Here is a small example,

import dash
import dash_html_components as html
import dash_core_components as dcc
import dash_leaflet as dl
import plotly.express as px

# Example graph.
df = px.data.iris()
fig = px.scatter(df, x="sepal_width", y="sepal_length")
graph = dcc.Graph(figure=fig, style={"width": "400px", "height": "250px"})
# Create map with marker.
app = dash.Dash()
app.layout = html.Div([
    dl.Map([dl.TileLayer(), dl.CircleMarker(center=(56, 10), children=dl.Tooltip(graph))],
           id="map", style={'width': '100%', 'height': '100vh', 'margin': "auto", "display": "block"}),
])

if __name__ == '__main__':
    app.run_server()

Disclaimer: I am the maintainer of Dash Leaflet.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.