Spatial plot land part in gray color
Show older comments
I am plotting a spatial plot, I want land parts should be in gray or white colour. The code I am attaching is not working
figure;
imagesc(lon, lat, corr_coeff_weak');
set(gca, 'YDir', 'normal');
colorbar;
colormap(redblue);
caxis([-1 1]);
xlabel('Longitude');
ylabel('Latitude');
title('Correlation for Weak SST Years');
hold on;
load coastlines;
fill(wrapTo360(coastlon), coastlat, 'w', 'EdgeColor', 'none'); % Fill land with white
plot(wrapTo360(coastlon), coastlat, 'k.', 'MarkerSize', 4);
axis xy;
2 Comments
Mathieu NOE
on 21 Jan 2025
hello
can you provide corr_coeff_weak data ?
Have you tried plotting your data using a map axes instead? With the axesm function you can specify to plot longitudes from 0 to 360 instead of -180 to +180. For example:
load coastlines
figure;
axesm('Robinson','MapLonLimit',[0 360])
fillm(coastlat,coastlon,'FaceColor','#505050','EdgeColor','none')
framem
gridm
box off
set(gca,'YColor','none','XColor','none')
Answers (0)
Categories
Find more on Mapping Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!