How can I scatter two vector with a condition on other vector in a matrix?
1 view (last 30 days)
If a have this matrix:
X Y Z
0 30 100
1 50 200
7 80 500
how could I scatter(Y,Z) with the condition of:
if X=0 then
scatter(Y, Z, sz,'filled','MarkerFaceColor', 'black')
(we scattered only the Y vs Z values where X>0)
if X>0 then
but the color of the points would be printed following a colormap and display on the graph a colorbar
any idea about how to make it?
AJ Geiger on 24 Jan 2018
Edited: AJ Geiger on 24 Jan 2018
sz = zeros(size(A,1),1);
% Note A must be 0 or greater-than 10 according
% to your logic, and therefore if x equals
% seven should be specified.
sz(A(:,1) == 0) = 5;
sz(A(:,1) > 10) = 10;
% follow the same logic for setting colors
% how ever you can not use the word 'black'
color = zeros(size(A,1),3);
color (A(:,1) == 0,:) = [.5,.5,.65];
color (A(:,1) > 10,:) = [0,0,0];
% note: the default color is
% black and is therefore redundent
scatter(Y, Z, sz,'filled','MarkerFaceColor',color)