Plotly JS modify z axis range

I’m plotiing a mesh3d type plot in plotlyjs using Plotly.newPlot command. Then through a button I’m trying to
set the zaxis range using

Plotly.relayout(graph, {'zaxis.range': [ -2,-1] });

But this doesn’t work and the axis range is set automatically. the button calls the command because lines before and after
the command gets executed. This method works perfectly for 2D plot. But its not working here. How do I do that.

This should be Plotly.relayout(graph, {'scene.zaxis.range': [-2, 1]})

for 3D subplots.

See 3d axes in JavaScript for more info.

1 Like