S = shaperead ('country_Boundary.shp');
lon = S.X;
lat = S.Y;
plot(lon, lat, '-k')
hold on
ax = gca;
xL = ax.XLim;
yL = ax.YLim;
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};
colorbar
start_color = sscanf('00ffff','%2x%2x%2x',[1 3])/255;
end_color = sscanf('0000ff','%2x%2x%2x',[1 3])/255;
num_colors = 100;
clrs =[linspace(start_color(1),end_color(1),num_colors)' linspace(start_color(2),end_color(2),num_colors)' linspace(start_color(3),end_color(3),num_colors)'];
colormap(clrs)
zlim = [min(z) max(z)]+[-0.1 +0.1];
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;
caxis([min(z) max(z)])
2 Comments
Direct link to this comment
https://in.mathworks.com/matlabcentral/answers/523398-is-it-possible-to-create-this-colormap-and-corresponding-colorbar-in-matlab#comment_842349
Direct link to this comment
https://in.mathworks.com/matlabcentral/answers/523398-is-it-possible-to-create-this-colormap-and-corresponding-colorbar-in-matlab#comment_842349
Direct link to this comment
https://in.mathworks.com/matlabcentral/answers/523398-is-it-possible-to-create-this-colormap-and-corresponding-colorbar-in-matlab#comment_842399
Direct link to this comment
https://in.mathworks.com/matlabcentral/answers/523398-is-it-possible-to-create-this-colormap-and-corresponding-colorbar-in-matlab#comment_842399
Sign in to comment.