Reputation: 179
I am plotting data in X-Y, x being time and y being that intensity at that point. However, I was wondering if I could change the type of marker based on a third value?
I am doing the following right now. I'd like to be able to set the marker shape based on a value from 1-6 in zVector, so the marker would be changing throughout the figure.
dataAdjusted = dlmread('file.csv');
xVector = dataAdjusted(:,1)
yVector = dataAdjusted(:,2)
zVector = dataAdjusted(:,3)
figure
hold on
plot(xVector, yVector, '-ro','MarkerSize',3, 'MarkerEdgeColor', 'k', 'MarkerFaceColor','k')
Upvotes: 3
Views: 657
Reputation: 26069
Here's an example how to accomplish that for z
values that go from 1 to 3 ...
x=rand(1,10);
y=rand(1,10);
z=randi(3,1,10);
plot(x(z==1),y(z==1),'o',...
x(z==2),y(z==2),'x',...
x(z==3),y(z==3),'s')
I think you can see how it can be generalized using a for loop quite easily.
Edit - here's a for loop implementation:
markerlist='sox';
colorlist='rgb';
for n=1:max(z)
plot(x(z==n), y(z==n), markerlist(n),'MarkerSize',5, 'MarkerEdgeColor', 'k', 'MarkerFaceColor',colorlist(n))
hold on
end
hold off
Upvotes: 3