How can I scatter two vector with a condition on other vector in a matrix?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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?
0 commentaires
Réponses (1)
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)
0 commentaires
Voir également
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!