'How to switch direction of axis in 3D scatterplot plotly?

I plotted the following using plotly and got the resulting plot shown before. X is the # of hours in a day, Y is a proportion between 0-1, and Z is a categorical variable with levels {0,1,2}.

However, it's unclear why the X seems to be going the opposite direction of what we're used to with a 3D Cartesian place where it's down(-) and up(+), left(-) and right(+), and front(-) and back(+). However, X seems to decrease from front to back instead of increase. I am new to plotly and am not sure how to flip the axis so it goes from 0 to 1 instead of 1 to 0. I would greatly appreciate help on this!

fig = px.scatter_3d(X_combined, x='x', y='y', z='z',
          color='set', symbol='predictions', opacity=0.7)

fig.update_traces(marker=dict(size=12,
                         line=dict(width=5,
                         color='Black')),
                  selector=dict(mode='markers'))

Plotly plot



Solution 1:[1]

For 3D plots, the options for axes are under layout.scene.
The autorange option is therefore located under layout.scene.xaxis.autorange and can be modified like this:

fig.update_scenes(xaxis_autorange="reversed")

References:

Solution 2:[2]

This should do the trick:

fig.update_xaxes(autorange="reversed")

Alternatively, you can reverse it with a specific range:

fig.update_xaxes(range=[9, 3])

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 LopDev
Solution 2