Interaction with the hover data in plotly

Viewed 494

The context

I am using plotly scatter_mapbox to plot some dataframe on a map. My dataframe has an important column (i.e.: "url") that I would like to be able to click on it when I hover my mouse on the point.

The problem

Unfortunately, the hover data is quickly disappearing and I am not able to click to copy paste, not to mention to go directly to the link.

The question

I am looking for a solution to have the hover_data hang on upon click.

Example

import pandas as pd
import plotly.io as pio
import plotly.express as px
pio.renderers.default='notebook'
pd.options.plotting.backend = "plotly"

df = px.data.carshare()
df['url'] = "https://google.com"

fig = px.scatter_mapbox(df, lat="centroid_lat", lon="centroid_lon", hover_name="car_hours",                     
                        hover_data= {
                            "url": True,   
                            "centroid_lat": False,
                            "centroid_lon": False
                        },
                        color_discrete_sequence=["fuchsia"], zoom=10, height=600)
fig.update_layout(mapbox_style="open-street-map")

Outputs:

Hover data

But, I am never able to click on the url (in this case: "https://google.com")

0 Answers
Related