How to plot discrete points as colormap?

27 次查看(过去 30 天)
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 中查找有关 Orange 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by