This is an example of using scatter3
to plot multiple variables. Changing marker type adds more functionality. Notice we still haven't made use of the S
(marker size) argument in scatter3(X,Y,Z,S,C)
.
However, this may not be a good visualization for some applications. Some other resources listed below.
% MATLAB R2017a
n = 50;
X = 10*rand(n,1);
Y = 15*rand(n,1);
Z = 20*rand(n,1);
V = 100*rand(n,1);
idxA = X + Y > 15;
idxB = ~idxA;
colormap(cmap), hold on, box on
p(1) = scatter3(X(idxA),Y(idxA),Z(idxA),[],V(idxA),'filled');
p(2) = scatter3(X(idxB),Y(idxB),Z(idxB),[],V(idxB),'filled');
p(2).Marker = 'd';
cb = colorbar;
view([-5 -2 -2])
p(1).MarkerEdgeColor = 'k';
p(2).MarkerEdgeColor = 'k';
xlabel('X')
ylabel('Y')
zlabel('Z')
cb.Label.String = 'V';
Other resources:
This post with 3D and 4D solutions. Future visitors may find this post valuable as well due to its many examples complete with code.
MATLAB references:
MATLAB Plot Types
MATLAB Plot Gallery