2

I have two 3D volume images and I want to locate one point from the first image (I have specific x, y, and z values for this point) and mark it with a different color. I mean how I can insert the values of x, y, and z and get this point in my graph inside all the points with a different color.

EBH
  • 10,350
  • 3
  • 34
  • 59
Sam
  • 53
  • 5
  • 2
    Have you tried 'hold on', and then just plot that individual point with whatever specified color you want? – Flynn Jul 24 '17 at 17:32

2 Answers2

1

Assuming you're using scatter3, you can just make your scatterplot, then use "hold on" and add a scatterplot with your single point in a different color that will cover the original point, e.g.:

hold on; 
scatter3(x,y,z,'MarkerEdgeColor','k','MarkerFaceColor',[0 .75 .75]);
Dandan
  • 143
  • 9
1

Here are 2 options:

Option 1

Use hold to overlay another scatter only with the points you want to color differently:

data = rand(100,3); % some data
p = randi(100); % choose some point
scatter3(data(:,1),data(:,2),data(:,3),'Fill')
hold on
% here you plot only one point (p):
scatter3(data(p,1),data(p,2),data(p,3),'r','Fill')
hold off

enter image description here

Option 2

If you want to color more than one point, and/or use different colors for your points, it may be better to set the color by the point when you call scatter in the first time:

data = rand(100,3); % some data
p = randi(size(data,1),5,1); % choose some points
c = ones(size(data,1),1); % default color
c(p) = 2:(numel(p)+1); % set different color for each points in p
col = lines(numel(p)+1); % set the colormap for the points
scatter3(data(:,1),data(:,2),data(:,3),[],col(c,:),'Fill')

enter image description here

EBH
  • 10,350
  • 3
  • 34
  • 59