Change color in 3d graphic scatter3

3 次查看(过去 30 天)
Hi, I need to change the colors of my 3d graphic. The y-axis data are grouped in 3 different groups (y=100, y=75, y=50), and I need each of those three groups to have a different color. My code is as follows:
clear;
pga_x = load('PGA.txt'); %textfile (115 data)
clt_y= load('CLT.txt'); %textfile (y=100, y=75, y=50)
energia_z=load('ENERGIA_ME.txt'); %textfile (115 data)
%c1_z= energia_z(:,1);
%c2_z= energia_z(:,2);
%c3_z= energia_z(:,3);
%c4_z= energia_z(:,4);
[xdata, ydata, zdata] = prepareSurfaceData(pga_x, clt_y, energia_z);
a = scatter3(xdata,ydata,zdata);
legend( a, 'Ajuste de curva Lineal', '%CLT vs. PGA(g), Energía embebida(MJ)', 'Location', 'NorthEast' );
xlabel('PGA (g)');
ylabel('%CLT');
zlabel('ENERGÍA EMBEBIDA (MJ)');
I appreciate if you can help me. My English is not very good, I speak Spanish and use translator.
I need it to look like in the following image, each group with a different color. Please help :'(

回答(1 个)

KSSV
KSSV 2022-10-21
You need to provide the color data.
a = scatter3(xdata,ydata,zdata,[],zdata,'filled');
colorbar

类别

Help CenterFile Exchange 中查找有关 Scatter Plots 的更多信息

产品


版本

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by