Plotly.js: streamtube coloring and positions depend on data order

Created on 19 Sep 2019  路  8Comments  路  Source: plotly/plotly.js

````
var gd = document.getElementById('graphDiv');

var type = 'streamtube';

var allX = [];
var allY = [];
var allZ = [];
var allU = [];
var allV = [];
var allW = [];

var res = 10;
var ni = res;
var nj = res;
var nk = res;
var i, j, k;

for(var k = 0; k < nk; k++) {
for(var j = 0; j < nj; j++) {
for(var i = 0; i < ni; i++) {
var x = i;
var y = j;
var z = k;

        allX.push(x);
        allY.push(y);
        allZ.push(z);

        var u = 0;
        var v = 0;
        var w = z;

        allU.push(u);
        allV.push(v);
        allW.push(w);

    }
}

}

var allX2 = [];
var allY2 = [];
var allZ2 = [];
var allU2 = [];
var allV2 = [];
var allW2 = [];

for(var k = 0; k < nk; k++) {
for(var j = 0; j < nj; j++) {
for(var i = 0; i < ni; i++) {
var x = k;
var y = j;
var z = i;

        allX2.push(x);
        allY2.push(y);
        allZ2.push(z);

        var u = 0;
        var v = 0;
        var w = z;

        allU2.push(u);
        allV2.push(v);
        allW2.push(w);

    }
}

}

Plotly.newPlot(gd, {
data: [{
type: type,
x: allX,
y: allY,
z: allZ,
u: allU,
v: allV,
w: allW,
scene: 'scene1'
},
{
type: type,
x: allX2,
y: allY2,
z: allZ2,
u: allU2,
v: allV2,
w: allW2,
scene: 'scene2'
},
],
layout: {
width: 1200,
height: 600,
scene1: {
domain: {
x: [0, 0.45]
}
},
scene2: {
domain: {
x: [0.5, 0.95]
}
},
}
}
);
````

newplot(2)

A codepen is available on https://codepen.io/emmanuelle-plotly/pen/PoYxZQv?editors=0010

I would not expect the viz to depend on whether x or z is the fastest varying variable.

bug

All 8 comments

In addition to color it looks there is a bug in the positions!
In your codepen if I change the trace type from streamtube to cone, it displays the full correct data.
Demo

Not sure about the cone plot sizes even: codepen

Not sure about the cone plot sizes even: codepen

See https://github.com/plotly/plotly.js/issues/3613 for that.

It appears that gl-streamtube3d module makes false assumption about the order of data!
https://github.com/gl-vis/gl-streamtube3d/blob/533bf21665b8849542756402ffc0800b932cffec/streamtube.js#L242-L249

Nice find @archmoj !

@emmanuelle what do you think of this fix?
codepen
Do the normals make sense e.g. when compared with cone.

Here is another example to help test changes.
codepen

Thank you @archmoj it looks good now :-)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

maxwell8888 picture maxwell8888  路  3Comments

tim-sauchuk picture tim-sauchuk  路  3Comments

mithi picture mithi  路  3Comments

hashimmoosavi picture hashimmoosavi  路  3Comments

emanuelsetitinger picture emanuelsetitinger  路  3Comments