MATLAB: 3D stem plot colored by Z-value

3d plotsstem3

Does anybody know how to vary the color of the scatter point and stem line in accordance to the Z-value for the 'stem3' plot function? Ideally the outcome of which would be similar to the purpose of 'C' for the 3D scatter plot: scatter3(X,Y,Z,S,C); where if C is a vector, its value is linearly mapped to the selected colormap. An example using the scatter3 function is:
V_dot_r = [0.027; 0.018; 0.018; 0.018; 0.0135];
V_dot_a = [2; 2; 1; 0.5; 0.5];
conv = [27, 33, 41, 50, 46];
scatter3(V_dot_r, V_dot_a, conv, 60, conv, 'filled')
colormap(cool)
colorbar
I would like to obtain a similar plot, however using the stem3 function rather than the scatter3 function. Is this possible?
Thanks in advance.

Best Answer

This requires a bit more code than I would like, partially because it needs to scale the colors appropriately to match the scatter3 appearance. The loop appears to be necessary to plot all the colors correctly. It took a bit of experimenting to get this.
The Code
figure
cm = colormap(cool(max(conv)-min(conv)));
hold all
for k1 = 1:numel(conv)
sh(k1) = stem3(V_dot_r(k1), V_dot_a(k1), conv(k1));
cm_idx = max( conv(k1)-min(conv), 1 );
set(sh(k1), 'Color',cm(cm_idx,:), 'MarkerFaceColor',cm(cm_idx,:), 'MarkerEdgeColor',cm(cm_idx,:))
end
hold off
colorbar
grid on
view(-37.5, 30)
xlabel('V\_dot\_r')
ylabel('V\_dot\_a')
zlabel('conv')
The Plot