How can you reverse an axis and set its range at the same time?

I need a plot in which my Y axis is reversed. However I also need to be able to set its range.
Using autorange reverse do reverse my axis but cannot set the range anymore.

How can I do this?

layout1= go.Layout(title=go.layout.Title(text="A graph",x=0.5),
        xaxis={'title':'y[m]','autorange':'reversed','range':[-10,10]},
        yaxis={'title':'x[m]', 'side':'right'})

# switch the x- and y-coordinates

point_plot=[

            go.Scatter(y=[3],x=[1],name="V0"),
            go.Scatter(y=[5],x=[2],name="GT"),
            go.Scatter(y=[0],x=[0],name="egoCar")

    ]

fig = go.Figure(data=point_plot, layout=layout1)

# reverse the range of the xaxis (which contains the y values)
#fig.update_xaxes(autorange="reversed")
fig.show()

Right now the Y axis is from 0 to 2 not -10,10

hi Kansai, were you able to resolve this issue, I happened to run the same issue still no luck, could you please share the ideas? thanks in advance!

Super old question, but I just came across it via a google search so I might as well add an answer…
Set a range [max, min] instead of [min, max] and it will be reversed.

3 Likes