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