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 #4557

Merged
merged 10 commits into from
Apr 24, 2024
Merged

Conversation

rl-utility-man
Copy link
Contributor

  1. added an example that formats the elements of custom_data in plotly express
  2. fixed a bug in the "advanced hovertemplate" example which caused it to display the square root of population. Modified that example to follow the main dataframe is called "df" convention. Added a country name field to that example and comments about the usage of key parameters.
  3. I did not remove the "Adding other data to the hover with customdata and a hovertemplate" example, but I believe it is now redundant and that the revised ### Advanced Hover Template example is more compliant with expectations like using meaningful data over random data. If you removed it, it would make sense to rename "Advanced Hover Template" to include the phrase: "Adding other data to the hover with customdata and a hovertemplate"

Documentation PR

  • [ X] I've seen the doc/README.md file
  • [ yes, 5.20!] This change runs in the current version of Plotly on PyPI and targets the doc-prod branch OR it targets the master branch
  • [ X] If this PR modifies the first example in a page or adds a new one, it is a px example if at all possible
  • [ X] Every new/modified example has a descriptive title and motivating sentence or paragraph
  • [ X] Every new/modified example is independently runnable
  • [ X ] Every new/modified example is optimized for short line count and focuses on the Plotly/visualization-related aspects of the example rather than the computation required to produce the data being visualized
  • [ X] Meaningful/relatable datasets are used for all new examples instead of randomly-generated data where possible
  • [N/A ] The random seed is set if using randomly-generated data in new/modified examples
  • [ N/A] New/modified remote datasets are loaded from https://plotly.github.io/datasets and added to https://github.com/plotly/datasets
  • [ X] Large computations are avoided in the new/modified examples in favour of loading remote datasets that represent the output of such computations
  • [ X] Imports are plotly.graph_objects as go / plotly.express as px / plotly.io as pio
  • [ X] Data frames are always called df
  • [ X ] fig = <something> call is high up in each new/modified example (either px.<something> or make_subplots or go.Figure)
  • [ X] Liberal use is made of fig.add_* and fig.update_* rather than go.Figure(data=..., layout=...) in every new/modified example
  • Specific adders and updaters like fig.add_shape and fig.update_xaxes are used instead of big fig.update_layout calls in every new/modified example
  • [X ] fig.show() is at the end of each new/modified example
  • [ X] plotly.plot() and plotly.iplot() are not used in any new/modified example
  • [ X] Hex codes for colors are not used in any new/modified example in favour of these nice ones

1)  added an example that formats the elements of custom_data in plotly express
2)  fixed a bug in the "advanced hovertemplate" example which caused it to display the square root of population.   Modified that example to follow the main dataframe is called "df" convention.  Added a country name field to that example and comments about the usage of key parameters.
3)  I did not remove the "Adding other data to the hover with customdata and a hovertemplate" example, but I believe it is now redundant and that the revised ### Advanced Hover Template example is more compliant with expectations like using meaningful data over random data.  If you removed it, it would make sense to rename "Advanced Hover Template" to include the phrase:  "Adding other data to the hover with customdata and a hovertemplate"
Copy link
Contributor

@Coding-with-Adam Coding-with-Adam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice catch with the square root population displaying.
This new code example is much better, @rl-utility-man . Thank you.

Although redundant, I think it's ok to keep the section on "Adding other data to the hover with customdata and a hovertemplate". Having an example with a different graph type can be helpful to some.

@Coding-with-Adam
Copy link
Contributor

@LiamConnors are you ok with these suggested commits?

@rl-utility-man
Copy link
Contributor Author

@LiamConnors is there anything I can do to help finish this up and get it merged? Thanks!

Co-authored-by: Adam <adam@plot.ly>
"<b>%{customdata[0]}</b><br>" +
"<b>%{customdata[1]}</b><br><br>" +
"GDP per Capita: %{x:$,.0f}<br>" +
"Life Expectation: %{y:.0f}<br>" +
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"Life Expectation: %{y:.0f}<br>" +
"Life Expectancy: %{y:.0f}<br>" +

@LiamConnors
Copy link
Member

Thanks for this PR @rl-utility-man !

@LiamConnors LiamConnors merged commit 2fa17d9 into plotly:doc-prod Apr 24, 2024
4 checks passed
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 this pull request may close these issues.

3 participants