フィルターのクリア

Overplotting of scatter points on top of coastlines

7 ビュー (過去 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 Center および File ExchangeGeographic Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by