How to plot discrete points as colormap?

27 visualizaciones (últimos 30 días)
Emerson De Souza
Emerson De Souza el 9 de Nov. de 2011
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

Respuesta aceptada

Patrick Kalita
Patrick Kalita el 9 de Nov. de 2011
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.

Más respuestas (0)

Categorías

Más información sobre Orange en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by