Change color in 3d graphic scatter3

3 ビュー (過去 30 日間)
Javiera Díaz Pavez
Javiera Díaz Pavez 2022 年 10 月 20 日
回答済み: KSSV 2022 年 10 月 21 日
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 Center および File ExchangeScatter Plots についてさらに検索

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by