[英]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.