I want to reverse the y-axis of the graph I've obtained for all the over-plots using plotly.graph_objects. I know reversing of the axis can be done using plotly.express. But I would like to know how to reverse the axis using plotly.graph_objects
:
You can use:
fig['layout']['yaxis']['autorange'] = "reversed"
and:
fig['layout']['xaxis']['autorange'] = "reversed"
Plot - default axis:
Code:
import plotly.graph_objects as go
import numpy as np
t = np.linspace(0, 5, 200)
y = np.sin(t)
fig = go.Figure(data=go.Scatter(x=t, y=y, mode='markers'))
fig.show()
Plot - reversed x axis:
Plot - reversed y axis:
Code - reversed axes:
import plotly.graph_objects as go
import numpy as np
t = np.linspace(0, 5, 200)
y = np.sin(t)
fig = go.Figure(data=go.Scatter(x=t, y=y, mode='markers'))
fig['layout']['xaxis']['autorange'] = "reversed"
fig['layout']['yaxis']['autorange'] = "reversed"
fig.show()