Skip to content

Instantly share code, notes, and snippets.

@hamletbatista
Created September 28, 2019 17:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hamletbatista/974efdd29d3ad890fba5f55d0aa554e2 to your computer and use it in GitHub Desktop.
Save hamletbatista/974efdd29d3ad890fba5f55d0aa554e2 to your computer and use it in GitHub Desktop.
#!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