Here’s my code, I have all the charts I need, but what if I had a gif I wanted to display for each drop down scenario?
Here’s what I have:
Here’s what I want, except a different gif for each scenario:
Current code
import os
import numpy as np
import pandas as pd
import plotly.graph_objects as go
from plotly.subplots import make_subplots
import pandas as pd
import re
Names = sorted(set(df["Name"]))
fig = make_subplots(
rows=3, cols=1,
shared_xaxes=True,
vertical_spacing=0.03,
x_title= "Frames",
specs=[[{"type": "table"}],
[{"type": "scatter"}],
[{"type": "scatter"}]],
subplot_titles=("Data", "Velocity", "Acceleration")
)
plot_names = [x]
buttons=[x]
default = "Mike Evans"
for name in Names:
play = df[(df["Name"]==name)]
fig.add_trace(
go.Scatter(
x=play["Frames"],
y=play["Accel"],
mode="lines",
name="Acceleration",visible=(name==default)
),
row=3, col=1
)
fig.add_trace(
go.Scatter(
x=play["Frames"],
y=play["Velocity"],
mode="lines",
name="Velocity",visible=(name==default)
),
row=2, col=1
)
fig.add_trace(
go.Table(visible=(name==default),
header=dict(
values=["playId", "Name", "route",
"Frames", "Accel", "Velocity",
"AccelMax", "dxMax"],
font=dict(size=10),
align="left"
),
cells=dict(
values=[play[k].tolist() for k in play.columns],
align = "left")
),
row=1, col=1
)
fig.update_layout(
height=800,
showlegend=False,
title_text="Players",
margin = {'t':75, 'l':50}
)
plot_names.extend([name]*3)
for name in Names:
buttons.append(dict(method='update',
label=name,
args = [{'visible': [name == r for r in plot_names]}]))
fig.update_layout(showlegend=False, updatemenus=[{"buttons": buttons, "direction": "down", "active": Names.index(default), "showactive": True, "x": 0.5, "y": 1.15}])
fig.show()