Overlaying two maps; how to reduce the density of dots in one map so that final map looks clearer

3 次查看(过去 30 天)
Hi,
I am trying to overlay two maps. The 1st one is a world map of Sen's slope. The 2nd one is a world map of Mann-Kendall test significance. The problem is when i overlay map 2 on map 1, the high density of the dots in map 2 (markers) clutter the final map. So in the final map, information of map 1 (Sen's slope) is not clear. Please see the attached final map (grey dots are too dense, so underlying colours are not clear).
Could somone please kindly suggest me a method to reduce the densisty of the dots (markers) in map 2, so that the final map looks clearer. Ideally, I would like to have some relatively large few dots instead of small dense clusters of dots.
I have added the code below.
Thanks in advance
tStart = tic;
load('SSandmMK.mat','De_Martonne_SS_map') % load the aridity database name
load('SSandmMK.mat','De_Martonne_mMK_map') % load the mMK test database name
load('Lati.mat') % load latitude data
load('Longi.mat') % load longitude data
lon = double(varname_0_data'); % conversion to double
lat = flip(double(varname_1_data)); % conversion to double and flipping
Lon = lon(ones(1,360),:); % creation of a mesh with lon data
Lat = lat(:,ones(1,720)); % creation of a mesh with lat data
SEN = De_Martonne_SS_map;
H = De_Martonne_mMK_map;
LL = -0.15; % color bar lower limit
HL = 0.15; % color bar upper limit
STP = 0.03; % color bar step
SEN = double(SEN); % conversion to double
H = double(H); % conversion to double
figure(1) % figure 1 sens slope
latax=-90:1:90; % lati range
lonax=-179.99:1:179.99; % lon range
ax = worldmap([latax(1),latax(end)],[lonax(1),lonax(end)]); % load world map
setm(ax,'mlabelparallel',-90);
setm(gca,'FLineWidth',1,'Grid','on','GLineWidth', 1.5, 'PLineLocation', [-90,-45,0,45,90],'PLabelRound', 0, 'PLineLocation', [-179.99,-135,-90,-45,0,45,90,135,179]);
setm(gca,'plabellocation',[-90,-45,0,45,90]);
setm(gca,'mlabellocation',[-179.99,-135,-90,-45,0,45,90,135,179]);
gridm('mlinelocation',[-179.99,-135,-90,-45,0,45,90,135,179.9],'plinelocation',[-90,-45,0,45,90]);
load coastlines
plotm(coastlat,coastlon)
hold on
e1 = rot90(pcolorm(Lat,Lon,SEN),2);
cbh=colorbar('v');
set(cbh,'XTick',[LL:STP:HL])
colormap (flip(jet(10)))
caxis([LL HL])
title('Sens slope - De Martonne Aridity 1901-2019')
figure(2) % figure 2 sens slope significance from mMK test
latax=-90:1:90;
lonax=-179.99:1:179.99;
ax = worldmap([latax(1),latax(end)],[lonax(1),lonax(end)]);
setm(ax,'mlabelparallel',-90);
setm(gca,'FLineWidth',1,'Grid','on','GLineWidth', 1.5, 'PLineLocation', [-90,-45,0,45,90],'PLabelRound', 0, 'PLineLocation', [-179.99,-135,-90,-45,0,45,90,135,179]);
setm(gca,'plabellocation',[-90,-45,0,45,90]);
setm(gca,'mlabellocation',[-179.99,-135,-90,-45,0,45,90,135,179]);
gridm('mlinelocation',[-179.99,-135,-90,-45,0,45,90,135,179.9],'plinelocation',[-90,-45,0,45,90]);
hold on
H(H==0)=NaN;
%e2 = rot90(pcolorm(Lat,Lon,H),2);
e2 = rot90(plotm(Lat,Lon,H,'.', 'MarkerSize',0.001, 'MarkerEdgeColor',[0.5 0.5 0.5], 'MarkerFaceColor','none'));
%set(e2,'facealpha',0.1);
cbh=colorbar('v');
set(cbh,'XTick',[0:1:1])
colormap (flip(gray(2)))
caxis([0 1])
hold on
load coastlines
plotm(coastlat,coastlon)
title('Statistical significance of Sens slope - De Martonne Aridity 1901-2019')
% Overlaying figure 2 on figure 1
first_fig = figure(1);
second_fig = figure(2);
first_ax = findobj(first_fig, 'type', 'axes');
second_ax = findobj(second_fig, 'type', 'axes');
if length(first_ax) ~= 1 || length(second_ax) ~= 1
error('this code requires the two figures to have exactly one axes each');
end
ch2 = get(second_ax, 'children'); % direct children only and don't try to find the hidden ones
copyobj(ch2, first_ax);
set(gcf, 'Renderer', 'painters')
print -depsc -tiff -r300 -painters untitled.eps
tEnd = toc(tStart)
  1 个评论
Sachindra Dhanapala Arachchige
Ok, I found a solution to this issue myself. The dot density in the second figure can be reduced by only plotting every nth row and mth column in the signifiance matrix H. For example say you want to only plot every 5th column and every 5th row of matrix H.
For that you can replace the following line in the above code
e2 = rot90(plotm(Lat,Lon,H,'.', 'MarkerSize',0.001, 'MarkerEdgeColor',[0.5 0.5 0.5], 'MarkerFaceColor','none'));
with
% select only every 5th row
Lat_R = Lat(1:4:end,:); % Lat = latitude matrix
Lon_R = Lon(1:4:end,:); % Lon = longitude matrix
H_R = H(1:4:end,:); % H = significance matrix
% select only every 5th column
Lat_C = Lat_R(:,1:4:end);
Lon_C = Lon_R(:,1:4:end);
H_C = H_R(:,1:4:end);
% then plot the reduced matrix H whcih is called H_C
e2 = rot90(plotm(Lat_C,Lon_C,H_C,'.', 'MarkerSize',2, 'MarkerEdgeColor','k', 'MarkerFaceColor','none'));

请先登录,再进行评论。

回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by