I want to Plot a Matrix (10x20), with 0, 1 or 2 in each
field. I used scatter, to get each type of Matrix-entry in a
different color, but my problem is that I cannot choose wich
colors the Points appear in (the matrix represents cells, 0
is no cell, 1 is normal cell, 2 is tumor cell) and i cant
make the points big enough.
how can i et white for 0, green for 1 and red for 2? how do
i add a legend, that dosn't only show '"green dot" - data'?
Thx
Barbara
> how can i et white for 0, green for 1 and red for 2?
One way is to reshape the matrix to a (x,y,c) vector
where (x,y) are the coordinates in your image and c
is the RGB value of the color:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
N=10;
M=20;
K=N*M; % Size of vector
X=repmat((1:N)',M,1); % Vector of x coordinates
Y=reshape(ones(N,1)*(1:M),K,1); % Vector of y coordinates
A=round(rand(K,1)*2); % Vector of data [0,1,2]
% Colors:
cmap=[1,1,1; % Black - shows better in figure.
0,1,0; % Green
1,0,0]; % Red
C = zeros(length(A),3); % Vector to conatin color codes
symbolsize = 100; % Select size of symbols
clf
% Find the colors which correspond to each item in A
for n=1:3
idx=find(A==n-1); % Find all elements with
given value
C=ones(length(idx),1)*cmap(n,:); % Insert color for current
value
scatter(X(idx),Y(idx),symbolsize,C,'filled') % Plot the data
hold on
end
legend('None','Good','Tumor')
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
> how do
> i add a legend, that dosn't only show '"green dot" - data'?
You have to use one call to SCATTER per color.
Rune
just make your colormap white green and red.
colormap([1 1 1;0 1 0;1 0 0])