plotly-express.histogram graph autorun not working
Code snippet:
import streamlit as st
import pandas as pd
import webbrowser
import plotly.express as px
import io
data='''
Time Value Name Type
0 6.9 A start
40 6.9 A start
120 6.9 A start
0 0.01 B start
40 0.01 B start
120 0.01 B start
0 1.0 C start
40 1.0 C start
120 1.0 C start
0 0.08 D start
40 0.08 D start
120 0.08 D start
0 0.000131 E End
40 0.00032 E End
120 0.99209 E End
0 0.002754 F End
40 0.00392 F End
120 0.01857 F End
0 0.003 G End
40 0.00516 G End
120 0.00746 G End
0 0.00426 H End
40 0.0043 H End
120 0.0095 H End
0 0 I End
40 0.0017 I End
120 0.0183 I End
'''
df = pd.read_csv(io.StringIO(data), delim_whitespace=True)
pmax = df['Value'].max()
pmin = df['Value'].min()
fig_bar = px.bar(df,x='Name',y='Value',color='Name',animation_frame='Time',facet_row='Type')
fig_bar.update_layout(yaxis_title="conc")
fig_bar.update_yaxes(matches=None)
fig_bar.for_each_yaxis(lambda yaxis: yaxis.update(showticklabels=True))
fig_bar.update_xaxes(matches=None)
fig_bar.for_each_xaxis(lambda xaxis: xaxis.update(showticklabels=True))
#fig_bar.update_yaxes(showgrid=True)
fig_bar.update_traces(hovertemplate='Time: %{y:.2f}'+'<br>Name: %{x}')
fig_bar.layout.updatemenus[0].buttons[0].args[1]["frame"]["duration"] = 1000
st.plotly_chart(fig_bar,auto_play=True)
fig_bar.write_html("test.html")
url = 'test.html'
webbrowser.open(url, new=2)
Expected behavior:
One can see histogram plot in streamlit need to press play button to run where as the same plot in webbrowser is running automatically. Is it possible for streamlit-plotly graph run automatically like auto_play=True.
B. Also the yaxis in top graph saying sum of value instead of conc
Actual behavior:
Explain the undesired behavior or error you see when you run the code above.
If you’re seeing an error message, share the full contents of the error message here.
Debug info
- Streamlit version: (get it with
$ streamlit version
) - Python version: (get it with
$ python --version
) - Using Conda? PipEnv? PyEnv? Pex?
- OS version:
- Browser version:
Requirements file
Using Conda? PipEnv? PyEnv? Pex? Share the contents of your requirements file here.
Not sure what a requirements file is? Check out this doc and add a requirements file to your app.
Links
- Link to your GitHub repo:
- Link to your deployed app:
Additional information
If needed, add any other context about the problem here.