Spatial plot land part in gray color

5 views (last 30 days)
Joydeb Saha
Joydeb Saha on 21 Jan 2025
Commented: Austin M. Weber on 21 Jan 2025
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
Mathieu NOE on 21 Jan 2025
hello
can you provide corr_coeff_weak data ?
Austin M. Weber
Austin M. Weber on 21 Jan 2025
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')

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!