How can I create a 3D grouped scatter plot in Statistics Toolbox 7.2 (R2009b)?

조회 수: 7 (최근 30일)
I want to plot a grouped scatter plot in 3D, similar to the 2D version created by GSCATTER.

채택된 답변

MathWorks Support Team
MathWorks Support Team 2009년 11월 10일
The ability to plot a 3D GSCATTER plot is not available in Statistics Toolbox 7.2 (R2009b).
To workaround this issue, you can first call GSCATTER with just the X and Y data and capture the output argument (the handles to the object created). Following that, use the handles to set the 'ZData' property. Here is an example:
% create random dataset
x = randn(200,1);
y = randn(200,1);
z = randn(200,1);
g = [1*ones(50,1); 2*ones(50,1); 3*ones(50,1); 4*ones(50,1); ];
% call GSCATTER and capture output argument (handles to lines)
h = gscatter(x, y, g);
% for each unique group in 'g', set the ZData property appropriately
gu = unique(g);
for k = 1:numel(gu)
set(h(k), 'ZData', z( g == gu(k) ));
end
view(3)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Scatter Plots에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

제품


릴리스

R2009b

Community Treasure Hunt

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

Start Hunting!

Translated by