scatterplot shows RowIDs as points and points as a color map
    조회 수: 4 (최근 30일)
  
       이전 댓글 표시
    

Hi,
I would like to plot a scatter plot but I would like to show the points in the scatterplot by point IDs. For example, if I have RowIDs from 1 to 10, I have two columns X and Y. I want to show a scatter plot of X and Y but the points should show the point IDs (1-10). Also, I would like to include a colormap so that these points have a color spectrum.
Can anybody suggest me a method how to implement in MATLAB? (Please see the image of what I want to do)
Thanks in advance.
댓글 수: 0
채택된 답변
  arich82
      
 2014년 5월 29일
        
      편집: arich82
      
 2014년 5월 29일
  
      Would something like this work?
n = 30; % number of data points
cmap = jet(n); % builtin colormap; could choose another...
C = mat2cell(cmap, ones(1, size(cmap, 1)), 3); % reshape for 'set'
% dummy data
k = [1:n].';
t = (k - 1)/n;
r = (t - 1).*cos(2*pi*2*sqrt(t));
%
x = 10*((1 + r)/2);
y = x;
z = t;
%figure('WindowStyle', 'docked');
%surf([x, x], [y, y], [z - eps, z + eps], 'EdgeColor', 'interp');
% plot numerical data
hf = figure('WindowStyle', 'docked');
ha = axes;
axis(ha, [0, 10, 0, 10]);
ht = text(x, y, num2str(k));
set(ht, {'Color'}, C)
set(ht, 'FontWeight', 'bold');
colormap(cmap);
colorbar;
Note: using the 'set' command with cell arrays can be a little cumbersome (in my opinion), as there seem to be a number of gotchas; you could just as easily loop through ht:
for ind = 1:n
  set(ht(ind), 'Color', cmap(ind, :));
end
Let me know if this works for you.
--Andy
댓글 수: 5
  arich82
      
 2014년 7월 8일
				I'm confused: I though you said "I would like to include a colormap so that these points have a color spectrum". Do you no longer want this? If not, simply omit the building and use of C.
It appears,
set(ht, {'Color'}, C)
is how you're changing the text color. Try omitting that line (place a % in front), or try
set(ht, 'Color', 'k'); % equvivalent to set(ht, 'Color', [0, 0, 0]);
to change all the text to black.
I hope this helps; please clarify what you're expecting if it doesn't.
추가 답변 (0개)
참고 항목
카테고리
				Help Center 및 File Exchange에서 Orange에 대해 자세히 알아보기
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

