How to plot discrete points as colormap?

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 日

2 投票

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 件)

カテゴリ

ヘルプ センター および File ExchangeColor and Styling についてさらに検索

製品

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by