필터 지우기
필터 지우기

How to plot discrete points as colormap?

조회 수: 37 (최근 30일)
Emerson De Souza
Emerson De Souza 2011년 11월 9일
INTRO:
I want to plot z as color dots of each x,y-coordinate-pair. Assume the array is given as in the example below:
xvector = 5:5:100;
yvector = 5:5:75;
numX = numel(xvector);
numY = numel(yvector);
yvector = repmat(yvector(:),numX,1);
xvector = repmat(xvector ,numY,1);
COORDINATES= [xvector(:) yvector];
VALUE=(1:1:numX*numY)';
T=[COORDINATES VALUE];
[ux, ~, bx] = unique(T(:,1));
[uy, ~, by] = unique(T(:,2));
[X, Y] = ndgrid(ux, uy);
%Z = accumarray( [bx(:),by(:)], T(:,3) );
Z = accumarray( [bx(:),by(:)], T(:,3), [],[], NaN );
%h=pcolor(X,Y,Z);
%h=surf(X,Y,Z);
h=surf(X,Y,zeros(size(X)),Z);
Colorbar;
axis([90 105 50 80]);
set(gca);
set(gca,'XTick',90:1:105);
set(gca,'YTick',50:1:80);
set(gca,'XMinorTick','on');
set(gca,'YMinorTick','on');
PROBLEM: It plots a color box everywhere but I want to display only the discrete values, the vacancies should be white or any known color.
I tried different plot commands above (%) but nothing changed the situation. Hope someone knows how to do it correctly. Thanks in advance for your help
Emerson

채택된 답변

Patrick Kalita
Patrick Kalita 2011년 11월 9일
I think you want to use scatter instead of surf. Take a look at the first example in the documentation page. It closely matches what you are trying to do.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Red에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by