How to set color gradient based on z axis?

Hi, I have this 3d scatter plot wher right now the color gradient is done by default and is being done in order of rows of data in the table, I was wondering if I can do the color gradient based on the z-axis values (like high to low)? Thanks!
hSc3 = scatter3(T.CED(ix),T.r(ix),T.E0(ix),'filled');
xlabel('ln(CED) (Pa)','fontweight','bold');
ylabel('Atomic Radius (pm)','fontweight','bold');
zlabel('E0 (V)','fontweight','bold');
NNZ = nnz(ix);
C = jet(NNZ);
hSc3.CData = C;
%T(ix,:)
hold on % don't let added stuff wipe out what we've already got drawn
hL=plot(nan(2,NNZ),'o');
set(hL,{'MarkerFaceColor'},num2cell(C,2),{'MarkerEdgeColor'},num2cell(C,2));
hLg=legend(hL,T.Element(ix));

Answers (1)

hSc3 = scatter3(T.CED(ix),T.r(ix),T.E0(ix),36,T.E0(ix),'filled');

Categories

Products

Release

R2023a

Tags

Asked:

on 30 Apr 2023

Answered:

on 30 Apr 2023

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!