How to plot pixels on the figure when I have coordinates of the center of each pixel

조회 수: 15 (최근 30일)
Hello,
I have the coordinates of the center of 93 0.5x0.5 pixels.
I want to plot them like this picture:
Here is my data which contains latitude, longitude, and also value.
Any suggestion or advice is highly appreciated.

채택된 답변

Ameer Hamza
Ameer Hamza 2020년 5월 5일
편집: Ameer Hamza 2020년 5월 5일
Try scatteredInterpolant()
x = points{:,1};
y = points{:,2};
z = points{:,3};
interp_model = scatteredInterpolant(x, y, z);
xg = linspace(min(x), max(x), 100);
yg = linspace(min(y), max(y), 100);
[Xg, Yg] = meshgrid(xg, yg);
Zg = interp_model(Xg, Yg);
pcolor(Xg, Yg, Zg)
or you can add
shading interp
after pcolor() to get a smooth surface
  댓글 수: 19
BN
BN 2020년 5월 7일
Dear Ameer Hamza,
I'm sorry but I have another problem here.
When I start comparing the figure from the first model and second model's pixels I found that the values of the color bar are different while the colors of pixels are similar. For example please look at these two pictures, the first one generated for the first model and the second one generated for the next model:
I have a yellow color in both but in the first one, it indicates values near 350 while in second figure yellow pixels show values about 140.
In order to compare, do you think there is any way to make color stable in both?
For example, yellow color in all figures of models shows near 300 values.
Here is an example and I have to compare more than 20 models.
Thank you again for your help.
Ameer Hamza
Ameer Hamza 2020년 5월 7일
Yes, It is possible, but that will make the points in some figures to be very similar. For example, If you set the limits of the color axis from 0 to 400 for all figures, then if the points lie between [127 130], they will have a very similar color. Try following code. I set the limits of color axis as [0 400]
s = shaperead('country_Boundary.shp');
%%
mapshow(s)
hold on
axis equal
ax = gca;
xL = ax.XLim;
yL = ax.YLim;
%%
load data
rect_x = [-0.25 -0.25 0.25 0.25];
rect_y = [0.25 -0.25 -0.25 0.25];
x = points{:,1};
y = points{:,2};
z = points{:,3};
num_colors = 200;
clrs = summer(num_colors);
zlim = [0 400];
clr_val = @(z) clrs(ceil(interp1(zlim, [0 1], z)*num_colors), :);
for i=1:numel(x)
p(i) = patch(rect_x + x(i), rect_y + y(i), ...
clr_val(z(i)), ...
'EdgeColor', 'none');
end
ax.XLim = xL;
ax.YLim = yL;
colorbar
colormap(summer)
caxis(zlim)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

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

태그

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by