I'm trying to plot some data, which consists of 4 variables. I'm using 2 approaches one is scatter plot and another one is surface. The problem is that when I'm using surface the data is missing. I think it has to do with the color setup.
For the scatter plot, I use this:
def scatter3d(x,y,z, cs, colorsMap='jet'):
cm = plt.get_cmap(colorsMap)
cNorm = matplotlib.colors.Normalize(vmin=min(cs), vmax=max(cs))
scalarMap = cmx.ScalarMappable(norm=cNorm, cmap=cm)
fig = plt.figure()
ax = Axes3D(fig)
ax.scatter(x, y, z,c=scalarMap.to_rgba(cs))
ax.set_xlabel('Thita1')
ax.set_ylabel('Thita2')
ax.set_zlabel('Fairness (%)')
scalarMap.set_array(cs)
fig.colorbar(scalarMap,label='Error Rate (%)')
plt.show()
I want to convert it to a surface plot, using this:
def surfacePlot(x,y,z, cs, colorsMap='jet'):
cm = plt.get_cmap(colorsMap)
cNorm = matplotlib.colors.Normalize(vmin=min(cs), vmax=max(cs))
scalarMap = cmx.ScalarMappable(norm=cNorm, cmap=cm)
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax.plot_surface(x, y, z, facecolors=scalarMap.to_rgba(cs))
ax.set_xlabel('Thita1')
ax.set_ylabel('Thita2')
ax.set_zlabel('Fairness')
scalarMap.set_array(cs)
fig.colorbar(scalarMap,label='Error Rate (%)')
plt.show()
However, this results in an empty grid:
Although the axes have received the min and max values from the vectors, the points are missing. What am I doing wrong ?