Overplotting of scatter points on top of coastlines
4 ビュー (過去 30 日間)
古いコメントを表示
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!
0 件のコメント
採用された回答
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
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
その他の回答 (1 件)
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();
参考
カテゴリ
Help Center および File Exchange で Geographic Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!