Black Lives Matter. Please consider donating to Black Girls Code today.

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 https://plot.ly/javascript/3d-axes/ for more info.

1 Like