Skip to content
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

Update hover-text-and-formatting.md #204

Open
wants to merge 1 commit into
base: master
from

Conversation

@yecatstevir
Copy link

@yecatstevir yecatstevir commented Nov 17, 2019

The chart was not plotting the correct country name with the data point in the hover. Just needed to pass in the 'continent' column data from the continent_data dictionary.

Doc upgrade checklist:

  • random seed is set if using random data
  • file has been moved from unconverted/x/y.md to x/y.md
  • old boilerplate at top and bottom of file has been removed
  • Every example is independently runnable and is optimized for short line count
  • no more plot() or iplot()
  • graph_objs has been renamed to graph_objects
  • fig = <something> call is high up in each example
  • minimal creation of intermediate trace objects
  • liberal use of add_trace and update_layout
  • fig.show() at the end of each example
  • px example at the top if appropriate
  • minimize usage of hex codes for colors in favour of those in https://github.com/plotly/plotly.py-docs/issues/14
The chart was not plotting the correct country name with the data point in the hover.  Just needed to pass in the 'continent' column data from the continent_data dictionary.
@emmanuelle
Copy link
Collaborator

@emmanuelle emmanuelle commented Nov 18, 2019

Thank you @yecatstevir ! In fact I just noticed there are several issues with this example: in the hovertemplate x and y are inverted, and the population is the square root of the right value. I believe this part of the code should be

for continent_name, continent in continent_data.items():
    fig.add_trace(go.Scatter(
        x=continent['gdpPercap'],
        y=continent['lifeExp'],
        name=continent_name,
        text=continent['country'],
        customdata=continent['pop'],
        hovertemplate=
        "<b>%{text}</b><br><br>" +
        "GDP per Capita: %{x:$,.0f}<br>" +
        "Life Expectation: %{y:.0f}<br>" +
        "Population: %{customdata:,}" +
        "<extra></extra>",
        marker_size=continent['size'],
        ))

Does this sound correct to you? Thanks for noticing the problem :-)

@yecatstevir
Copy link
Author

@yecatstevir yecatstevir commented Nov 18, 2019

@emmanuelle
Copy link
Collaborator

@emmanuelle emmanuelle commented Nov 19, 2019

Happy to know you're having fun with Plotly ;-). Would you like to give it a try and make the other changes to this example?

@yecatstevir
Copy link
Author

@yecatstevir yecatstevir commented Nov 19, 2019

Ah yes, sorry about that, I will go back to take a look.

@nicolaskruchten
Copy link
Member

@nicolaskruchten nicolaskruchten commented Dec 3, 2019

@emmanuelle if you have a chance, could you please move this over to the plotly.py repo, with the other fixes you found?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.