繁体   English   中英

将固定比率轴与 plotly.express facetrow / facetcol 一起使用

[英]Use fiexed ratio axes with plotly.express facetrow / facetcol

是否有可能将固定比率轴与plotly.express通过使用facetrow / facetcol创建的子图结合使用

这个例子工作得很好:

import plotly.express as px
df = px.data.iris()
fig = px.scatter(df, x="sepal_width", y="sepal_length", facet_col='species')

fig.update_layout(yaxis=dict(scaleanchor="x", scaleratio=1))

一旦我添加了facetrow参数,它就不会调整轴。 我可以使用layout = go.Layout(yaxis=dict(scaleanchor="x", scaleratio=1))为子图设置默认布局layout = go.Layout(yaxis=dict(scaleanchor="x", scaleratio=1))

在此处输入图片说明

感谢您的帮助,

索伦

在创建方面plotly.express将轴匹配在一起,以便您可以在缩放、平移等时同步子图。此行为与约束轴纵横比不兼容。 下面禁用轴匹配的代码给出了所需的行为:

import plotly.express as px
df = px.data.iris()
fig = px.scatter(df, x="sepal_width", y="sepal_length", facet_col='species')

fig.update_yaxes(matches=None, showticklabels=True)
fig.update_xaxes(matches=None)
fig.update_layout(yaxis=dict(scaleanchor="x"))
fig.update_layout(yaxis2=dict(scaleanchor="x2"))
fig.update_layout(yaxis3=dict(scaleanchor="x2"))
fig.show()

情节表达方面

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM