'Is there any way to animate a preexisting slider in plotly?
r = np.linspace(-1,1,1000)
intervr = 1/2
theta_const = np.arange(0,90+intervr,intervr)
figr=go.Figure()
for i in theta_const:
xr,yr,zr = coords_r(r,i)
figr.add_trace(go.Scatter(
x=r,y=magB(xr,yr,zr,xpos,ypos,zpos,0.1*165),
line=dict(color="#e10534",width=2.5)
))
labelr = theta_const.astype(int)
stepsr=[]
for i in range(len(figr.data)):
stepr = dict(
method="update",
label=str(labelr[i]),
args=[
{"visible":[False]*len(figr.data)},
{"title":"B(r) for Theta(Deg) ="+str(labelr[i])}
]
)
stepr["args"][0]["visible"][i]=True
stepsr.append(stepr)
slidersr = [dict(
currentvalue={"prefix":"Theta(Deg)="},
steps=stepsr
)]
figr.update_layout(sliders=slidersr)
figr.update_xaxes(title="R(m)")
figr.update_yaxes(title="B(T)")
figr.show()
Ok, so I have this figure already made that outputs several graphs and shows only one, depending on where the slider is. What I want to know is if it is possible to just animate this slider with this preexisting figure, or is that not possible? (Ive tried to follow plotly's example of sliders + buttons but I just cant understand it as there is so much going on in it).
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
