我想使用plotly.graph_objects反转为所有过度绘制获得的图的y轴。我知道可以使用plotly.express来完成轴的反转。但是我想知道如何使用plotly.graph_objects
反转轴:
最佳答案
您可以使用:
fig['layout']['yaxis']['autorange'] = "reversed"
和:fig['layout']['xaxis']['autorange'] = "reversed"
绘图-默认轴:代码:
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()
绘图-x轴反转:图-y轴反转:
代码-反转轴:
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()
关于python - 密谋:如何反转轴?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59100115/