简体   繁体   中英

How do I remove the category from a plotly hovertemplate?

I have plotted a plotly express "px.scatter_mapbox", and cannot remove the right hand side box indicating the category. I've searched but can't figure out how to remove it (see highlighted box in the image below)

截屏 ).

fig = px.scatter_mapbox(thisplotdf, lat="Latitude", lon="Longitude", 
                        custom_data=['Station', 'Average', 'Compliant'],
                        color="Compliant", 
                        color_continuous_scale="jet",
                        zoom=4.5, height=300,opacity=0.7)

fig.update_traces(marker=dict(size=20),
                  hovertemplate=("<br>".join([
                      "<b>%{customdata[0]}</b>",
                      "<i>PM2.5 [ug/m3]</i>: %{customdata[1]}",
                      "%{customdata[2]}"])
                                )
                 )

Does anyone know how to do this? Thank you!

You can add the tag <extra></extra> in the hovertemplate :

fig.update_traces(marker=dict(size=20),
                  hovertemplate=("<br>".join([
                      "<b>%{customdata[0]}</b>",
                      "<i>PM2.5 [ug/m3]</i>: %{customdata[1]}",
                      "%{customdata[2]}"])
                                )+"<extra></extra>"
                 )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM