Created
September 28, 2019 17:47
-
-
Save hamletbatista/974efdd29d3ad890fba5f55d0aa554e2 to your computer and use it in GitHub Desktop.
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
#!pip install plotly-express | |
import pandas as pd | |
from urllib.parse import urlparse | |
from collections import Counter | |
import plotly.express as px | |
import plotly | |
import plotly.graph_objects as go | |
fig = px.scatter(df, x="Average Wait Time", y="Ride Duration", color="Ride", symbol="Ride", height=900, width=1200) | |
annotations = [] | |
show_arrows = ["Disneyland Railroad Tomorrowland Station", | |
"Disneyland Railroad New Orleans Square Station", | |
"Disneyland Railroad Main Street Station", | |
"Mr. Toad's Wild Ride"] | |
for row in df.to_dict(orient="rows"): | |
if row['Ride'] in show_arrows: | |
showarrow = True | |
else: | |
showarrow = False | |
annotations.append(go.layout.Annotation( | |
x=row['Average Wait Time'], | |
y=row['Ride Duration'], | |
text=row['Ride'], | |
showarrow=showarrow | |
)) | |
fig.update_layout( | |
showlegend=True, | |
annotations=annotations | |
) | |
fig.update_layout(legend_orientation="h") | |
fig.update_traces(textposition='top right') | |
fig.show(config={'editable': True}) | |
plotly.offline.plot(fig, filename='ridetimes.html') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment