Show the numbers in one color in scatterplot

Hi,
Please look at the following code. I need to show the points (as numbers) in black color. But it is showing in different colors according to the colormap. How can I make it show all the points (as numbers) in black color (just one color).
Thanks in advance.
n = 6; % number of data points
cmap = jet(n); % builtin colormap; could choose another...
C = mat2cell(cmap, ones(1, size(cmap, 1)), 3); % reshape for 'set'
k = [1:n].';
marker_size = 25;
marker_type = 's'
xlim([2 6]),ylim([2 6])
ht = text(Ob_All_avg, WGEN_All_avg, num2str(k));
set(ht, {'Color'}, C)
set(ht, 'FontWeight', 'bold','FontSize',18,'edgecolor','none');
colormap(cmap);
box on
line([2,6],[2,6],...
'linewidth',0.6,...
'color',[1,0,0],'LineStyle','--');
set(gca,...
'xlim',[2,6],...
'ylim',[2,6]);
axis square;
xlabel('TRMM (1998-2012)','FontSize',14)
ylabel('WGEN generated 10000 yrs','FontSize',14)
title('Daily Mean','FontSize',14)

댓글 수: 3

Geoff Hayes
Geoff Hayes 2014년 7월 7일
편집: Geoff Hayes 2014년 7월 7일
Damith - where is the line (or lines?) of code that is used to plot the data via scatter? Unless you mean the line of code
ht = text(Ob_All_avg, WGEN_All_avg, num2str(k));
which displays the numbers from 1 through 6 at coordinates defined by Ob_All_avg and WGEN_All_avg which does plot the numbers using the colormap defined by jet(n).
If you want these numbers just in black then just remove the lines
cmap = jet(n); % builtin colormap; could choose another...
C = mat2cell(cmap, ones(1, size(cmap, 1)), 3); % reshape for 'set'
and later
set(ht, {'Color'}, C)
which sets the colour of the text (numbers) to that of the colour map. With these three lines gone, the default colour of black should be used.
Damith
Damith 2014년 7월 7일
Thanks Geoff. Your suggestions worked. :)
Awesome!

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

도움말 센터File Exchange에서 Blue에 대해 자세히 알아보기

질문:

2014년 7월 7일

댓글:

2014년 7월 7일

Community Treasure Hunt

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

Start Hunting!

Translated by