필터 지우기
필터 지우기

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 CenterFile Exchange에서 Graphics Objects에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by