如何使用 Plotly Express 绘制一个有两个 Y 轴的图表,一个在左,一个在右?
我发现Plotly Express比Plotly更有效。go,这是我的问题: 如何使用Plotly Express绘制一个带有两个Yaxis的图表,一个在Rihgt上绘制一个图表?
我正在尝试绘制一个tickdata图表,该图表用AskPrice和sha sma =“询问价格 - 出价价格”, 原因差和询问价格的规模不同,所以我想绘制两张Yasix图片, 我做到了 但是,两个Yaxis标签都在左侧 我该如何分开Yaxis?
fig = px.line(df, x="datetime", y=\['sma_spread', "sma_plus", "sma_minus"\])
fig2 = px.scatter(df,x=df\['datetime'\], y=\['a1', "b1"\])
fig2.update_traces(yaxis ="y2")
show(fig.add_traces(fig2.data))
I found out that Plotly express is more efficient than plotly.go, here is my question:
how to use Plotly express draw a chart with two Yaxis, one on left, one on rihgt?
I am trying to draw a chart of tickdata that with askprice and tha sma of spread ="ask price - bid price",
cause spread and ask price is different in scale , so i want to draw a two yasix picture,
i did
but, the two yaxis label are both on left side
how can i Separate the yaxis?
fig = px.line(df, x="datetime", y=\['sma_spread', "sma_plus", "sma_minus"\])
fig2 = px.scatter(df,x=df\['datetime'\], y=\['a1', "b1"\])
fig2.update_traces(yaxis ="y2")
show(fig.add_traces(fig2.data))
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
update_layout(yaxis2 = {“叠加层”:“ y”,“ side”:“ right”})
完整MWE的
结构相同
update_layout(yaxis2={"overlaying":"y", "side":"right"})
full MWE