フィルターのクリア

Assign certain colors to certain dots of a scatter plot

1 回表示 (過去 30 日間)
Antonio
Antonio 2017 年 4 月 20 日
編集済み: Antonio 2017 年 4 月 21 日
Hey y'all,
I need to assign certain colors to certain dots of a scatter plot. I've written something like this:
Color = zeros(size(Check,1),1);
for i = 1:size(Check,1)
if Check(i) == 0
Color(i) = [0.3010 0.7450 0.9330];
elseif Check(i) == 1
Color(i) = [0.4660 0.6740 0.1880];
elseif Check(i) == 2
Color(i) = [0.9290 0.6940 0.1250];
elseif Check(i) == 3
Color(i) = [0.8500 0.3250 0.0980];
elseif Check(i) == 4
Color(i) = [0.6350 0.0780 0.1840];
end
end
scatter(x,y,Color,'filled','s');
Beware that 'x', 'y', 'Color' and 'Check' have the same dimension (15000 x 1). Numbers in 'Check' are either '0', '1', '2', '3', or '4'. I just need to assign five different colors to my scatter plot based on the numbers I have in 'Check' matrix. The colors should be those that I used in the code as I need this plot to match with another bar chart I already have. Any help will be highly appreciated!
  1 件のコメント
Image Analyst
Image Analyst 2017 年 4 月 20 日
You're welcome! That was easy - I didn't even have to do anything.

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeGraphics Objects についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by