OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Plotly geo mapbox - toggle points based on row value

  • Thread starter Thread starter Vessel
  • Start date Start date
V

Vessel

Guest
I've got a plotly mapbox setup like this

Code:
fig = px.scatter_mapbox(
    data,
    lat="Latitude",
    lon="Longitude",
    zoom=4,
    height=0,
    color="Engagement",
    mapbox_style="carto-darkmatter",
    hover_data={
        "Latitude": False,
        "Longitude": False,
        "Engagement": False,
        "1st study": True,
    },
)

fig.update_layout(
    margin={"r": 0, "t": 0, "l": 0, "b": 0},
    hoverlabel=dict(bgcolor="black", font_size=16, font_family="Lato"),
)

colour_map = {1: "#ff0000", 2: "#2a00ff", 3: "#1be43c"}

colours = [colour_map[val] for val in data["Engagement"]]

fig.update_traces(marker=dict(size=6, color=colours))
fig.show()

Is there a way of adding e.g. a checkbox to the map to make the points toggleable based on the Engagement value?
<p>I've got a plotly <code>mapbox</code> setup like this</p>
<pre class="lang-py prettyprint-override"><code>fig = px.scatter_mapbox(
data,
lat="Latitude",
lon="Longitude",
zoom=4,
height=0,
color="Engagement",
mapbox_style="carto-darkmatter",
hover_data={
"Latitude": False,
"Longitude": False,
"Engagement": False,
"1st study": True,
},
)

fig.update_layout(
margin={"r": 0, "t": 0, "l": 0, "b": 0},
hoverlabel=dict(bgcolor="black", font_size=16, font_family="Lato"),
)

colour_map = {1: "#ff0000", 2: "#2a00ff", 3: "#1be43c"}

colours = [colour_map[val] for val in data["Engagement"]]

fig.update_traces(marker=dict(size=6, color=colours))
fig.show()
</code></pre>
<p>Is there a way of adding e.g. a checkbox to the map to make the points toggleable based on the <code>Engagement</code> value?</p>
 

Latest posts

Online statistics

Members online
0
Guests online
5
Total visitors
5
Top