-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
update_yaxes behavior for make_subplots vs specifying axes directly #5213
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
example code for method 1 - using subplots, update_yaxes modifies all three axes import plotly.graph_objects as go df = data.stocks() fig = make_subplots(rows=3, cols=1, shared_xaxes=True, vertical_spacing=0.03) fig.add_trace(go.Scatter(x=df["date"], y=df["AAPL"], name="Apple"), row=1, col=1) fig.show() |
example code for method 2 - specifying axis directly, update_yaxes only modifies the behavior of the first subplot import plotly.graph_objects as go df = data.stocks() layout = dict( data = [ fig = go.Figure(data=data, layout=layout) |
Update_yaxes’ documentation states that the supposed behavior is to modify all y-axes at once, link “By default, these methods apply to all of the x axes or y axes in the figure. The row and col arguments can be used to control which axes are targeted by the update.” method 1’s fig.layout: method 2’s fig.layout: The function is able to recognise that it needs to modify yaxis, yaxis2, etc, but only when creating subplots via method 1. |
--copied from the plotly forum here https://community.plotly.com/t/update-yaxes-behavior-when-using-make-subplots-vs-specifying-axes-directly/92496--
To my knowledge, there’s two main ways to create subplots:
make_subplots(), then add trace data - example here
create list of data, inject into go.Figure() - example here (see hover on subplots)
I’m not sure which one’s the preferred one, but update_yaxes affects them differently.
If we use method 1, the update_yaxes affects all yaxes as intended
If we use method 2, the update_yaxes only affects the first subplot
Is there a reason why update_yaxes doesn’t play well with the second way of creating subplots?
The text was updated successfully, but these errors were encountered: