Plotly Scatter Points on Maps – Removing Longitude and Latitude from text


I am following this example very closely to experiment with plotting scatter points on maps and this is working perfectly:

However, when you hover over each scatter point you will notice the text is shown along with the latitude and longitude. Is there a way to remove the two coordinates from the displayed text?

Asked By: Odisseo



You should be able to set hoverinfo="text" to achieve this. Here is the relevant documentation page:

Answered By: nicolaskruchten

Though lat/lon is include by default in scatter_geo and scatter_mapbox, there are two ways to customize values include in the tooltip and both use the hover_data parameter.

From the docs:

hover_data: list of str or int, or Series or array-like, or dict

Passing a list/array only adds elements to the tooltip. To completely control what is displayed (in your case excluding lat/lon) pass in a dictionary with column names as keys and True/False as values. e.g.

fig = px.scatter_mapbox(data, 
Answered By: gojandrooo