Overplotting of scatter points on top of coastlines
7 次查看(过去 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!