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

1 回表示 (過去 30 日間)
Philippe Corner
Philippe Corner 2018 年 1 月 24 日
編集済み: AJ Geiger 2018 年 1 月 24 日
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 Center および File ExchangeScatter Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by