How to set color gradient based on z axis?

19 views (last 30 days)
Andrew
Andrew on 30 Apr 2023
Answered: Adam Danz on 30 Apr 2023
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)

Adam Danz
Adam Danz on 30 Apr 2023
hSc3 = scatter3(T.CED(ix),T.r(ix),T.E0(ix),36,T.E0(ix),'filled');

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Tags

Products


Release

R2023a

Community Treasure Hunt

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

Start Hunting!