필터 지우기
필터 지우기

Plotting portion of a color coded scatter plot using a for loop

조회 수: 4 (최근 30일)
AN
AN 2023년 4월 11일
댓글: AN 2023년 4월 11일
Hi all,
I have created a value-based color coded 4-dimensional scatter plot of a heart (color coded based on activation times corresponding to each xyz point). The xyz coordinates are designated by vectors (x_points, etc...) and the corresponding colors to each xyz point are defined in an nx3 array called rgb_time. I have divided the scatter plot into cubic voxels using discretize, and am attempting to create scatter plots of individual voxels displaying the same color code of the original scatterplot. I am using the following code to loop through the points and determine the ones within the voxel of interest before plotting them:
i_max = 6; %arbitrary value
%graph only the cube containing the most colors (area of interest)
figure()
hold on
for i = 1:size(rgb_time)
if voxelIDs(i) == i_max
scatter3(x_points(i),y_points(i),z_points(i),20,rgb_time(i),'filled')
xlabel('x');ylabel('y');zlabel('z');title('voxel containing isochronal crowding');
str = 'early - red - orange - yellow - green - cyan - blue - purple - pink - late';
end
end
For some reason, however, the resultant voxel plot has distorted colors that are not the same as those displayed on the original scatter plot. Could anyone have an idea as to why this is? I have tried moving the hold on statement to various locations to no avail. Thank you!
  댓글 수: 1
AN
AN 2023년 4월 11일
I have attached examples of the original scatter plot with the desired colored regions, as well as a subset/voxel scatter plot with distorted colors.

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

채택된 답변

Ran Yang
Ran Yang 2023년 4월 11일
편집: Ran Yang 2023년 4월 11일
rgb_time is a Nx3 array, so you need to call all 3 columns using rgb_time(i, :) to get the color for each voxel. (Right now you're only getting column 1).

추가 답변 (0개)

카테고리

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

제품


릴리스

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by