Reputation: 63
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.
Upvotes: 2
Views: 349
Reputation: 10450
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
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')
Upvotes: 1
Reputation: 143
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]);
Upvotes: 1