Hi, I am working on a Jupyter Notebook and trying to implement a click event on a scattermapbox plot, and this seems to work when I change mode=âmarkers+textâ to mode=âmarkersâ, but when I do this, I get a ValueError:
invalid property path âmapbox._derivedâ for layout
It must be something small, as it works for all the other types, and I would very much appreciate it if someone could have a look at the code below:
Import libraries
import pandas as pd
import numpy as np
import plotly.express as px
import plotly.graph_objects as go
import json
import ipywidgets as widgets
from ipywidgets import Output, VBox
from plotly.graph_objs import FigureWidget
from plotly.callbacks import Points, InputDeviceState
data2 = go.Scattermapbox(lat=list(heat_df.ycoord),
lon=list(heat_df.xcoord),
mode=âmarkersâ,
marker=dict(size=20, color=âgreenâ),
)
layout = dict(margin=dict(l=0, t=0, r=0, b=0, pad=0),
f2 = go.FigureWidget(data=[data2], layout=layout);
f2.update_layout(mapbox_style=âstamen-terrainâ
, mapbox_center = {âlatâ: map_meanY, âlonâ: map_meanX}
, mapbox_zoom= 11
#, clickmode=âevent+selectâ
);
scatter = f2.data[0]
f2.layout.hovermode = âclosestâ
out = Output()
@out.capture(clear_output=True)
def click_callback(trace, points, selector):
inds = points.point_inds
print(inds)
#the click event
scatter.on_click(click_callback)
widgets.VBox([widgets.HBox([reset, export]), widgets.VBox([f2, out])])