3D Surface plots Plotly.js Doubt

I have 50 x, y, z data points.
x : [3, 4, 6, 5, 5, 4, 6, 5, 1, 3, 2, 0, 1, 0, 2, 4, 5, 0, 2, 3, 5, 5, 0, 1, 4, 0, 2, 3, 4, 6, 4, 0, 4, 5, 6, 6, 4, 4, 3, 4, 6, 2, 1, 1, 5, 2, 6, 0, 2, 2]
y : [3, 1, 6, 2, 5, 2, 2, 4, 6, 3, 1, 4, 3, 0, 1, 2, 4, 3, 2, 5, 0, 1, 0, 4, 1, 1, 4, 3, 2, 1, 0, 3, 6, 5, 1, 5, 4, 4, 0, 6, 3, 6, 6, 3, 2, 3, 2, 5, 0, 1]
z : [5, 1, 4, 5, 3, 1, 5, 6, 0, 1, 1, 3, 3, 2, 4, 3, 5, 2, 0, 1, 6, 0, 2, 6, 0, 1, 6, 2, 2, 0, 6, 5, 2, 2, 0, 5, 6, 6, 5, 4, 6, 1, 2, 2, 4, 3, 3, 0, 0, 0]

I used the following code to generate “Z” 2D array Data

from scipy.interpolate import griddata
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import cm
from mpl_toolkits.mplot3d import Axes3D

x=np.asarray([3, 4, 6, 5, 5, 4, 6, 5, 1, 3, 2, 0, 1, 0, 2, 4, 5, 0, 2, 3, 5, 5, 0, 1, 4, 0, 2, 3, 4, 6, 4, 0, 4, 5, 6, 6, 4, 4, 3, 4, 6, 2, 1, 1, 5, 2, 6, 0, 2, 2]);
y=np.asarray([3, 1, 6, 2, 5, 2, 2, 4, 6, 3, 1, 4, 3, 0, 1, 2, 4, 3, 2, 5, 0, 1, 0, 4, 1, 1, 4, 3, 2, 1, 0, 3, 6, 5, 1, 5, 4, 4, 0, 6, 3, 6, 6, 3, 2, 3, 2, 5, 0, 1]);
z=np.asarray([5, 1, 4, 5, 3, 1, 5, 6, 0, 1, 1, 3, 3, 2, 4, 3, 5, 2, 0, 1, 6, 0, 2, 6, 0, 1, 6, 2, 2, 0, 6, 5, 2, 2, 0, 5, 6, 6, 5, 4, 6, 1, 2, 2, 4, 3, 3, 0, 0, 0]);

xi=np.linspace(min(x), max(x),10)
yi=np.linspace(min(y),max(y),10)
zi = griddata((x,y), z, (xi, yi), method='linear')

X,Y= np.meshgrid(xi,yi)
Z = np.nan_to_num(griddata((x,y), z, (X, Y), method='cubic'))

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax.scatter(x, y, z)
ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=cm.coolwarm,
                       linewidth=0, antialiased=False)

plt.savefig('surface.pdf')

print type(Z)

print "["
for row in Z:
    print str(list(row)) + ","
print "]"

Am i correct in what i am doing ?

Following is my output till now. :

I was tring to use “TEXT” attribute of 3D scatter plot but i dont know why its not working. Here is the codepen:
http://codepen.io/rudi8292/pen/zBWjJP

Also how to use scattercolor attribute. I read a community post where in scattercolor is used but i didnt understand it.
I went throught the following code :
https://plot.ly/~RPlotBot/1149.js

I didnt understand how color scale is used.

1 Like

i figured out that i have to use 2D array for the text attribute to be visible, Though not all the text points are seen

text : [[‘Size :12’, ‘Size :17’, ‘Size :10’, ‘Size :15’, ‘Size :13’, ‘Size :15’, ‘Size :18’, ‘Size :17’, ‘Size :11’, ‘Size :15’, ‘Size :10’, ‘Size :19’, ‘Size :10’, ‘Size :18’, ‘Size :14’, ‘Size :14’, ‘Size :19’, ‘Size :10’, ‘Size :12’, ‘Size :13’, ‘Size :15’, ‘Size :13’, ‘Size :14’, ‘Size :11’, ‘Size :12’, ‘Size :14’, ‘Size :19’, ‘Size :18’, ‘Size :16’, ‘Size :14’, ‘Size :18’, ‘Size :10’, ‘Size :10’, ‘Size :18’, ‘Size :18’, ‘Size :10’, ‘Size :14’, ‘Size :16’, ‘Size :17’, ‘Size :19’, ‘Size :18’, ‘Size :10’, ‘Size :17’, ‘Size :17’, ‘Size :14’, ‘Size :13’, ‘Size :17’, ‘Size :17’, ‘Size :13’, ‘Size :16’]
],

Something like this

1 Like