Overplotting of scatter points on top of coastlines

조회 수: 8 (최근 30일)
Mathan
Mathan 2023년 12월 12일
댓글: Mathan 2023년 12월 13일
Hi all,
I am having a hard time figuring out how to plot a scatter plot on top of a worldmap without obscuring the coastlines. I have'nt used much of geoshow but I tried the following:
heat_data = load('struct.mat');
heat_data = heat_data.struct;
lat = heat_data.lat;
lon = heat_data.lon;
heat = heat_data.heat;
load coastlines
worldmap([-70,20],[-180,180])
geo = geoshow(coastlat,coastlon,"DisplayType","polygon","FaceColor",[1 1 1],'LineWidth',3);
sc = scatterm(lat,lon,75,heat,'filled','s');
sc.Children.MarkerFaceAlpha = 0.5;
sc.Children.MarkerEdgeAlpha = 0.5;
setm(gca,'FontSize',15) % setting fontsize of lat, lon ticklabels
setm(gca,'GLineWidth',2.5)
setm(gca,'GColor','k')
set(geo,'LineWidth',3)
%%%¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤ Setting the colormap
colormap('jet')
caxis([0 20000])
col = colorbar();
As clearly seen, while doing the scatter plot on top of the worldmap, most of the coastlines of South America and the southern part of Africa are not visible. I tried to reduce the transparency of the scatter markers but still they dont seem to work. However, I am able to adjust the thickness of the grid lines which seems unaffected by the color markers, even though adjusting the thickness of the coastlines are not working!
Does anyone have a lead to circumvent this?
Thanks a lot!

채택된 답변

Cris LaPierre
Cris LaPierre 2023년 12월 12일
Why not reverse the plot order? Plot your scatter first, and then your coastlines on top of them?
I did have to modify some of the settings in geoshow so that the land area does not block the scatter points.
heat_data = load('struct.mat');
heat_data = heat_data.struct;
lat = heat_data.lat;
lon = heat_data.lon;
heat = heat_data.heat;
load coastlines
worldmap([-70,20],[-180,180])
sc = scatterm(lat,lon,75,heat,'filled','s');
geo = geoshow(coastlat,coastlon,'LineWidth',3,'Color','k');
sc.Children.MarkerFaceAlpha = 0.5;
sc.Children.MarkerEdgeAlpha = 0.5;
setm(gca,'FontSize',15) % setting fontsize of lat, lon ticklabels
setm(gca,'GLineWidth',2.5)
setm(gca,'GColor','k')
set(geo,'LineWidth',3)
%%%¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤ Setting the colormap
colormap('jet')
caxis([0 20000])
col = colorbar();
  댓글 수: 3
Cris LaPierre
Cris LaPierre 2023년 12월 13일
Here is your original code
geo = geoshow(coastlat,coastlon,"DisplayType","polygon","FaceColor",[1 1 1],'LineWidth',3);
Here is the updated code in my answer
geo = geoshow(coastlat,coastlon,'LineWidth',3,'Color','k');
You can find the axes-based map properties page here: https://www.mathworks.com/help/map/ref/axesm-properties.html
Mathan
Mathan 2023년 12월 13일
Thanks Cris.

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

추가 답변 (1개)

Walter Roberson
Walter Roberson 2023년 12월 12일
편집: Walter Roberson 2023년 12월 12일
As well as long placing the scatterm() on the bottom, you need to watch out for the face color, because the face normally blocks view of what is behind it.
heat_data = load('struct.mat');
heat_data = heat_data.struct;
lat = heat_data.lat;
lon = heat_data.lon;
heat = heat_data.heat;
load coastlines
worldmap([-70,20],[-180,180])
sc = scatterm(lat,lon,75,heat,'filled','s');
geo = geoshow(coastlat,coastlon,"DisplayType","polygon", "FaceColor", 'none', "EdgeColor", 'k', 'LineWidth',3);
sc.Children.MarkerFaceAlpha = 0.5;
sc.Children.MarkerEdgeAlpha = 0.5;
setm(gca,'FontSize',15) % setting fontsize of lat, lon ticklabels
setm(gca,'GLineWidth',2.5)
setm(gca,'GColor','k')
set(geo,'LineWidth',3)
%%%¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤ Setting the colormap
colormap('jet')
caxis([0 20000])
col = colorbar();
  댓글 수: 1
Mathan
Mathan 2023년 12월 12일
Thanks Walter for the answer as well. I think I can accept only one answer but really appreciate the quick response.

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

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by