python - 密谋:如何反转轴?

标签 python plotly data-visualization

我想使用plotly.graph_objects反转为所有过度绘制获得的图的y轴。我知道可以使用plotly.express来完成轴的反转。但是我想知道如何使用plotly.graph_objects反转轴:

最佳答案

您可以使用:

fig['layout']['yaxis']['autorange'] = "reversed"
和:
fig['layout']['xaxis']['autorange'] = "reversed"
绘图-默认轴:
enter image description here
代码:
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轴反转:
enter image description here
图-y轴反转:
enter image description here
代码-反转轴:
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/

相关文章:

python + 写入文件的分号写在下一行

Plotly:如何在图的右侧添加空间

r - 如何在与特定文本匹配的ggplot中突出显示geom_text

python - gae-sessions 和 nose 的错误

Python - SQLAlchemy 使用exists() 检查数据是否已在表中?

如果 TCPServer 在另一个线程中运行,Python 2 不处理信号

python - 如何将热图注释为子图?

python - 是否可以更改 Plotly 中图例框的大小?

r - 在 ggplot2 中使用 facet_grid 进行成对值(热图)可视化

python - Altair 的累积计数