Created
November 17, 2020 07:17
-
-
Save tomron/6efe5086e6c22003732a1352c43a458b to your computer and use it in GitHub Desktop.
Add links to Plotly bar chart
This file contains 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
import pandas as pd | |
import plotly.graph_objects as go | |
df = pd.read_csv("https://raw.githubusercontent.com/plotly/datasets/master/2014_world_gdp_with_codes.csv") | |
df = df.sort_values(by='GDP (BILLIONS)', ascending=False).head(10) | |
fig = go.Figure([go.Bar(x=list(range(len(df))), y=df['GDP (BILLIONS)'])]) | |
fig.update_xaxes(tickmode = 'array', | |
tickvals = list(range(len(df))), | |
ticktext= df['COUNTRY'].apply(lambda x: f'<a href="https://en.wikipedia.org/wiki/{x}">{x}</a>')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment