✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
πŸ‡ Announcing Dash VTK for 3d simulation graphics. Check out the March webinar.

Plotly express animation autoscale

Hi there,
I made a simple dist plot however am unsure of how to enable automatic autoscale without pressing the autoscale button before I run the animation.

import plotly.express as px
import pandas as pd

df = pd.read_csv('/Users/mythilisutharson/documents/cam_work/mof_explorer_flourish/MOF_trans_data2.csv')
fig = px.histogram(df, x="Density (g/cm3)", marginal="rug", animation_frame="Pressure (bar)",
                   hover_data=df.columns, hover_name="DDEC code")
fig.show()

My datasheet can be found here:

Thank you!!

Hi @msuths1, it’s not possible to autoscale across frames but you can specify the range of your axis as follows

import plotly.express as px
import pandas as pd

df = pd.read_csv('/home/emma/MOF_trans_data2.csv')
fig = px.histogram(df, x="Density (g/cm3)", marginal="rug", animation_frame="Pressure (bar)",
                   hover_data=df.columns, hover_name="DDEC code")
fig.update_layout(xaxis_range=(0, df["Density (g/cm3)"].max()),
                 yaxis_range=(0, 300))
fig.show()
1 Like