Created
March 7, 2022 00:56
-
-
Save audhiaprilliant/57a899733ec71f57496b9700b23171d8 to your computer and use it in GitHub Desktop.
Introduction to Plotly
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 3 Sort the bar in descending order | |
| # Sort the data frame by sales | |
| df.sort_values( | |
| by = ['Sales'], | |
| ascending = False, | |
| ignore_index = True, | |
| inplace = True | |
| ) | |
| # Create object of figure | |
| fig = go.Figure() | |
| # Create a bar plot | |
| fig.add_trace( | |
| go.Bar( | |
| x = df['Fruit'], | |
| y = df['Sales'] | |
| ) | |
| ) | |
| # Config for title, background, legend etc | |
| fig.update_layout( | |
| plot_bgcolor = 'white', | |
| font = { | |
| 'color': '#797979' | |
| } | |
| ) | |
| # Show graph | |
| fig.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment