Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
rpanai opened this issue Jun 2, 2020 · 0 comments · Fixed by #2544
Closed

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

rpanai opened this issue Jun 2, 2020 · 0 comments · Fixed by #2544
Assignees

Comments

@rpanai
Copy link

rpanai commented Jun 2, 2020

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()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants