필터 지우기
필터 지우기

How to plot 3D scatter plot with legends?

조회 수: 39 (최근 30일)
Mallikarjun Yelameli
Mallikarjun Yelameli 2017년 7월 12일
댓글: Hussein 2023년 12월 29일
I want to plot 3D scatter plot, change in colour with the label attached to the data point. Is it possible in Matlab or simply should I just move to "ggplot" package and learn R language which is best in graphics and it is free as well? Just let me know. Thank You.

답변 (1개)

KSSV
KSSV 2017년 7월 12일
편집: KSSV 2017년 7월 12일
N = 10 ;
x1 = rand(N,1) ; y1 = rand(N,1); z1 = rand(N,1) ;
x2 = rand(N,1) ; y2 = rand(N,1); z2 = rand(N,1) ;
x3 = rand(N,1) ; y3 = rand(N,1); z3 = rand(N,1) ;
figure
hold on
scatter3(x1,y1,z1,'MarkerEdgeColor','r','MarkerFaceColor',rand(1,3))
scatter3(x2,y2,z2,'MarkerEdgeColor','b','MarkerFaceColor',rand(1,3))
scatter3(x3,y3,z3,'MarkerEdgeColor','g','MarkerFaceColor',rand(1,3))
legend([{'First'},{'Second'},{'Third'}])
  댓글 수: 1
Hussein
Hussein 2023년 12월 29일
Why do you need the curly brackets in the legend ?
i believe it works like this:
legend('First','Second','Third');

댓글을 달려면 로그인하십시오.

카테고리

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