Why AutoRange doesn't work?

Hi all,

I have set the autorange=True for xaxis :

import plotly.graph_objs as go
fig = go.Figure()

for i in range(5):
    fig.add_shape(type="circle", xref="x", yref="y", x0=i*5, y0=-1, x1=i*5+4, y1=4,)

fig.update_xaxes(title_text='x',automargin=True,autorange=True,title_font=dict(size=18, family='Courier', color='black')) #mirror=True


But the results is in this way:

Why autorange doesn’t work?


My first reaction is to say that this is a bug when there are no traces in the figure. I know it would have worked correctly when both traces and shapes are present.

Would adding fig.add_trace(go.Scatter(x=[], y=[])) fix the problem?

1 Like