Defining scatter plot with different 'markers' & 'colors'

3 次查看(过去 30 天)
Hi i am plotting a 3D scatter plot however i have to mark all 12 different classes on the 4th colomun in the attached file with 12 different markers and colors. Is there a way to randomize the 12 colors and markers all do i have to define them one by one? l only know how to do up till the 3d plot. Thanks in advance! :)
function plot3Ddata(x,y,z)
test = xlsread('HQ3.xlsx', 'A2:C223');
x=test(:,1);
y=test(:,2);
z=test(:,3);
scatter3(x,y,z);
end
the above code is my code for now...

采纳的回答

Rik
Rik 2020-2-23
This should be close to what you need:
test = xlsread('HQ3.xlsx', 'A2:D223');
x=test(:,1);
y=test(:,2);
z=test(:,3);
groups=test(:,4);
figure(1),clf(1)
for g=1:max(groups)
L=groups==g;
scatter3(x(L),y(L),z(L),...
'DisplayName',sprintf('group %d',g));
hold on
end
hold off
legend
  3 个评论
kenneth lee
kenneth lee 2020-3-13
Hi so sorry for the late response, but is there a possibility to make all of them with different shapes and colors as i wan to distinctively reseperate them for better visualisation. Thanks alot for the follow up, really appreciate it! :)
Rik
Rik 2020-3-13
If you don't want circles you can use plot3 instead of scatter3. Then you can set the LineSpec to whatever spec you like.

请先登录,再进行评论。

更多回答(0 个)

类别

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

Community Treasure Hunt

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

Start Hunting!

Translated by