Skip to content

hover_data formatting don't work if labels is assigned. #2529

Closed
@rpanai

Description

@rpanai

I'm working with the latest version plotly.__version__ == '4.8.1'. If I add labels the formatting in hover_data is not working.

import pandas as pd
import plotly.express as px

diz = {'bins': {0: 'till 500',
  1: 'till 500',
  2: '501-600',
  3: '501-600',
  4: 'more 601',
  5: 'more 601'},
 'data': {0: 4, 1: 26, 2: 15, 3: 35, 4: 41, 5: 9},
 'longitude': {0: 12.5,
  1: 65.5,
  2: 122.58333,
  3: 12.58333,
  4: -115.53333,
  5: 55.53333},
 'latitude': {0: 27.5, 1: 29.5, 2: 45.36667, 3: 55.36667, 4: 38.08, 5: -38.08},
 'names': {0: 'Name2',
  1: 'Name4',
  2: 'Name1',
  3: 'Name5',
  4: 'Name3',
  5: 'Name6'}}

df = pd.DataFrame(diz)

fig = px.scatter_geo(df,
                     lon='longitude',
                     lat='latitude',
                     color='bins',
                     color_discrete_sequence=px.colors.qualitative.Set1,
                     hover_name="names",
                     size='data',
                     opacity=0.7,
                     projection="equirectangular",
                     size_max=35,
                     hover_data={"longitude": False,
                                 "latitude": False,
                                 "names": False,
                                 "data": ":.2f"},
                    # If one comment out the following two lines
                   # "data" is formatted as in hover_data
                     labels={"bins": "Bin",
                                  "data": "Data"}
                   )
fig.show()

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions