簡體   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