Change color in 3d graphic scatter3
3 views (last 30 days)
Show older comments
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 :'(
0 Comments
Answers (1)
KSSV
on 21 Oct 2022
You need to provide the color data.
a = scatter3(xdata,ydata,zdata,[],zdata,'filled');
colorbar
0 Comments
See Also
Categories
Find more on Scatter Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!