I am trying to plot a 3D column with associated density.
Specifically, I have a .txt
file with 4 separate columns x, y, z, density
. The first 3 columns are the cartesian coordinates of the column, density a list of density values associated with each cross-section, at height z, of the column.
I can plot the column with a colormap as follows
x=np.linspace(-1, 1, 100)
z=np.linspace(-20, 5, 50)
Xc, Zc=np.meshgrid(x, z)
Yc = np.sqrt(1-Xc**2)
# Draw parameters
rstride = 1
cstride = 1
surf1 = ax.plot_surface(Xc, Yc, Zc, alpha=1., rstride=rstride, cstride=cstride,antialiased=False, cmap=cm.coolwarm,linewidth=0)
surf2 = ax.plot_surface(Xc, -Yc, Zc, alpha=1., rstride=rstride, cstride=cstride, antialiased=False, cmap=cm.coolwarm,linewidth=0)
and I can associate a colormap to z
fig.colorbar(surf1, shrink=0.5, aspect=5)
I would like to associate the colormap to the values in the fourth column, while maintaining the plotted dimensions of the cylinder constant.
I would appreciate any help on the matter.
Thanks.