How do I plot x,y, and an intensity value on an xy-plane with the intensity on a color scale?

조회 수: 3 (최근 30일)
I have this code right now:
% Make an image of the points, then apply a colormap
x = x(:); % Extract x value
y = y(:); % Extract y value
v=v(:);
%find max and min values
minX = min(x,[],1);
maxX = max(x,[],1);
minY = min(y,[],1);
maxY = max(y,[],1);
%dealing with NaN
v(isnan(v)) = 0; %set all NaN to zero
minV=0;
maxV=max(v,[],1);
% Make image be 500 by 700
rows = 500;
columns = 700;
grayImage = zeros(rows, columns, 'uint8');
for k = 1 : length(x)
row = ceil((y(k) - minY) * rows / (maxY - minY));
column = ceil((x(k) - minX) * columns / (maxX - minX));
if (row == 0)
row = 1;
end
if (column == 0)
column = 1;
end
grayImage(row, column) = uint8(255 * (v(k) - minV) / (maxV - minV));
end
imshow(grayImage);
colorbar;
% Colormap is not gray scale.
% Apply some other colormap if you want
colormap(jet(256))

답변 (1개)

Walter Roberson
Walter Roberson 2017년 9월 25일
cmap = jet(256);
imshow(grayImage, cmap);
colorbar();

카테고리

Help CenterFile Exchange에서 Color and Styling에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by