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

1 vue (au cours des 30 derniers jours)
Philippe Corner
Philippe Corner le 24 Jan 2018
Modifié(e) : AJ Geiger le 24 Jan 2018
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?

Réponses (1)

AJ Geiger
AJ Geiger le 24 Jan 2018
Modifié(e) : AJ Geiger le 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)

Catégories

En savoir plus sur Scatter Plots dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by