我正在试着找出两者之间的区别:
-
fig.update_layout({'yaxis': dict(matches=None)})
个 -
fig.update_yaxes(matches=None)
个
我以为它们是一样的,但是fig.update_layout({'yaxis': dict(matches=None)})
个不会像预期的那样改变yAxis.
以下是示例代码:
import plotly.express as px
import plotly
print("plotly version: " , plotly.__version__)
# Sample data
data = {
'Variable': ['A', 'A', 'B', 'B', 'C', 'C'],
'Value': [1, 2, 3, 4, 5, 6]
}
# Create box plot
fig = px.box(data, y='Value', facet_row='Variable')
fig.update_layout(height=400, width =400)
fig.update_layout({'yaxis': dict(matches=None)})
fig.show()
fig.update_yaxes(matches=None)
fig.show()
输出: