0

Anyone know if there is a way to do a multiple-surface chart (and if so, how), such as the bottom one shown at https://plot.ly/python/3d-surface-plots/, but using the javascript plot.ly api instead of the python one?

2 Answers 2

2

To reproduce any plotly graph you see on the plotly cloud, append .js to the graph's URL:

e.g. https://plot.ly/~PlotBot/685.js

Sign up to request clarification or add additional context in comments.

Comments

1

This Codepen:

http://codepen.io/plotly/pen/GogNjj

Should be helpful.

HTML Code:

<html>
<head>
<script src="http://cdn.plot.ly/plotly-latest.min.js"></script>
</head>
<body>
<!-- Plotly chart will be drawn inside this DIV -->
<div id="example"></div>
<script>

z1 = [
    [8.83,8.89,8.81,8.87,8.9,8.87],
    [8.89,8.94,8.85,8.94,8.96,8.92],
    [8.84,8.9,8.82,8.92,8.93,8.91],
    [8.79,8.85,8.79,8.9,8.94,8.92],
    [8.79,8.88,8.81,8.9,8.95,8.92],
    [8.8,8.82,8.78,8.91,8.94,8.92],
    [8.75,8.78,8.77,8.91,8.95,8.92],
    [8.8,8.8,8.77,8.91,8.95,8.94],
    [8.74,8.81,8.76,8.93,8.98,8.99],
    [8.89,8.99,8.92,9.1,9.13,9.11],
    [8.97,8.97,8.91,9.09,9.11,9.11],
    [9.04,9.08,9.05,9.25,9.28,9.27],
    [9,9.01,9,9.2,9.23,9.2],
    [8.99,8.99,8.98,9.18,9.2,9.19],
    [8.93,8.97,8.97,9.18,9.2,9.18]
];

z2 = [];
for (var i=0;i<z1.length;i++ ) { 
    z2_row = [];
    for(var j=0;j<z1[i].length;j++) { 
        z2_row.push(z1[i][j]+1);
    }
    z2.push(z2_row);
}

z3 = []
for (var i=0;i<z1.length;i++ ) { 
    z3_row = [];
    for(var j=0;j<z1[i].length;j++) { 
        z3_row.push(z1[i][j]-1);
    }
    z3.push(z3_row);
}
var data_z1 = {z: z1, type: 'surface'};
var data_z2 = {z: z2, showscale: false, opacity:0.9, type: 'surface'};
var data_z3 = {z: z3, showscale: false, opacity:0.9, type: 'surface'};



Plotly.newPlot('example', [data_z1, data_z2, data_z3]);
 </script>

</body>
</html>

2 Comments

This is the same example as the document. I still don't understand it.
we take three datasets for three surfaces (z1, z2, z3), and plot them in a single figure, with showscale set to False for the latter two ..

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.