How can I scatter two vector with a condition on other vector in a matrix?

1 次查看(过去 30 天)
If a have this matrix:
A:
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
sz=5;
scatter(Y, Z, sz,'filled','MarkerFaceColor', 'black')
hold on
(we scattered only the Y vs Z values where X>0)
and,
if X>0 then
sz=10;
scatter(d1_10,d1, sz,'filled')
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?

回答(1 个)

AJ Geiger
AJ Geiger 2018-1-24
编辑:AJ Geiger 2018-1-24
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)

类别

Help CenterFile Exchange 中查找有关 Scatter Plots 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by