Reputation: 455
I have the following minimal reproducible example and can't find how to change the z-axis range for the subplots
import plotly.graph_objects as go
from plotly.subplots import make_subplots
import numpy as np
main_fig = make_subplots(
rows= 4,
cols= 4,
specs = [[{'type': 'surface'} for k in range(4)] for j in range(4)],
horizontal_spacing = 0.05,
vertical_spacing=0.05)
axis = np.arange(50)
for k, spec in enumerate(range(16)):
fig = go.Surface(x=axis, y=axis, z=axis[:,None] * axis[None,:], showscale=False)
main_fig.append_trace(fig, row = k//4 + 1, col = k%4 + 1)
main_fig.update_traces(showlegend=False)
main_fig.update_layout(height=800, width=800)
I tried with variations of fig.update_layout
inside the loop, so far without luck.
Upvotes: 1
Views: 774
Reputation: 820
The short solution to set some attributes of each scene is as follows:
main_fig.update_scenes(zaxis=dict(nticks=4, range=[0,1000]))
Now print(main_fig.layout)
to inspect the scenes new settings.
Upvotes: 2
Reputation: 35240
To adjust the 3D axes, adjust the xyz axis in the section called scene, respectively. Please refer to the reference for examples. I set all z-axes manually, but I am sure there are more efficient codes.
main_fig.update_layout(
scene=dict(zaxis=dict(nticks=4, range=[0,1000])),
scene1=dict(zaxis=dict(nticks=4, range=[0,1000])),
scene2=dict(zaxis=dict(nticks=4, range=[0,1000])),
scene3=dict(zaxis=dict(nticks=4, range=[0,1000])),
scene4=dict(zaxis=dict(nticks=4, range=[0,1000])),
scene5=dict(zaxis=dict(nticks=4, range=[0,1000])),
scene6=dict(zaxis=dict(nticks=4, range=[0,1000])),
scene7=dict(zaxis=dict(nticks=4, range=[0,1000])),
scene8=dict(zaxis=dict(nticks=4, range=[0,1000])),
scene9=dict(zaxis=dict(nticks=4, range=[0,1000])),
scene10=dict(zaxis=dict(nticks=4, range=[0,1000])),
scene11=dict(zaxis=dict(nticks=4, range=[0,1000])),
scene12=dict(zaxis=dict(nticks=4, range=[0,1000])),
scene13=dict(zaxis=dict(nticks=4, range=[0,1000])),
scene14=dict(zaxis=dict(nticks=4, range=[0,1000])),
scene15=dict(zaxis=dict(nticks=4, range=[0,1000])),
scene16=dict(zaxis=dict(nticks=4, range=[0,1000]))
)
Upvotes: 1