# Auto scale Plotly express

**URL:** <https://community.plotly.com/t/auto-scale-plotly-express/33364>\
**Category:** 📊 Plotly Python\
**Created:** [January 8, 2020, 3:32pm UTC](https://community.plotly.com/t/auto-scale-plotly-express/33364 "2020-01-08T15:32:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![msuths1](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/msuths1/32/8990_2.png) [@msuths1](https://community.plotly.com/u/msuths1)\
**Post date:** [January 8, 2020, 3:32pm UTC](https://community.plotly.com/t/auto-scale-plotly-express/33364/1 "2020-01-08T15:32:12Z")

</div>

Hi,  
My x and y-axis are not automatically scaling as my plot progresses through its animation. I have to use the autoscale button at the end of the animation to overcome this.  
I have tried  
Animate = False,  
autorange=True in .update\_xaxes and .update\_yaxes,  
autosize=True in .update\_layout,  
range\_x=[0, x], range\_y=[0, y],

My code is below:

```auto
import plotly.express as px
import pandas as pd
import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output
import flask

server = flask.Flask( __name__ )
app = dash.Dash( __name__ , server=server)

dataset = pd.read_csv('/Users/mythilisutharson/documents/cam_work/mof_explorer_flourish/MOF_trans_data_bad_edit.csv')
col_options = [dict(label=x, value=x) for x in dataset.columns]
features = dataset.columns

styles = {
    'pre': {}
}
tabs_styles = {}
tab_style = {}

tab_selected_style = {}

dimensions = ['select x variable', 'select y variable ', 'select color variable', 'select size variable']
app.layout = html.Div(
    [
        html.H1("", style={}),
        html.Div(" ", style={}),
                            html.Div([dcc.Graph(id="graph", animate=False,
                                                ), ],
                                     style={"width": "80%", "display": "inline-block"}),
                            html.Div(
                                [
                                    html.P([d + ":", dcc.Dropdown(id=d,
                                                                  options=[{'label': i, 'value': i} for i in features
                                                                           ])])
                                    for d in dimensions

                                ],
                                style={'display': 'inline-block', 'width': '25%', 'fontSize': 14,
                                       'font-family': 'Arial'},

                            ),
    ], style={} # style for outter div
)

@app.callback(Output("graph", "figure"), [Input(d, "value") for d in dimensions])
def make_figure(x, y, color, size):
    return px.scatter(dataset, x=x, y=y, title="MOF Explorer", animation_frame="Pressure",
                      animation_group="DDEC Code", size=size, color=color,
                      hover_name="DDEC Code", color_continuous_scale='Viridis',
                      hover_data={"DDEC Code", "Density", "Void Fraction"}, template="plotly_white",

                      ).update_xaxes(showgrid=False, title=x, autorange=True, fixedrange=False).update_yaxes(
        showgrid=False, title=y, autorange=True, fixedrange=False).update_layout(
        clickmode='event+select', hovermode='closest', margin={'l': 50, 'b': 80, 't': 50, 'r': 10}, autosize=True
    )

app.run_server(debug=True)

```

And the data for this file can be accessed here:

> **[MOF\_trans\_data\_bad\_edit2.csv](https://drive.google.com/file/d/1VB_FoVWOPr-tdTTi85zuly5ieZi3BgeV/view?usp=sharing)**
>
> Google Drive file.

  
Thank you!

---

<div class="post-metadata">

**Author:** ![alvaro](https://avatars.discourse-cdn.com/v4/letter/a/839c29/32.png) [@alvaro](https://community.plotly.com/u/alvaro)\
**Post date:** [September 9, 2020, 2:48pm UTC](https://community.plotly.com/t/auto-scale-plotly-express/33364/2 "2020-09-09T14:48:11Z")

</div>

> [@msuths1](#):
>
> n at the end of the ani

did you manage to solve it?
