We can plot data with polygon in MATLAB as a data size of 651*1200*12 S.X and S.Y shows the X and Y values of polygon.

for i = 1:12
pcolor(lon1,lat1,data(:,:,i)) ;
shading interp ; 
geoshow([S.Y], [S.X],'Color','black');
axis tight

This method plots the all data both in and outside polygon but I have to plot data only inside the polygon. So how we can plot the data only inside polygon and put specific colour(white/black/green etc) to area outside the polygon.

enter image description here

The above is the output of my way.

Yet, I want to get this kind of plot:

enter image description here

Only plot the data inside polygon with least gap between subplots both by row and column.

  • Looks like raster data to me. Cant you overlay the data with a white non-transparent ocean polygon? – BERA Feb 18 at 7:43
  • it is point data extracted from netcdf format and we can overlay the data with any polygon of same projection but I want to plot the data only inside polygon. – irfan Feb 18 at 7:52

I found the way to plot the point only inside polygon

S = shaperead(polygon);
N = length(S);
[X,Y] = meshgrid(lon1,lat1);
data= test;
for k = 1:N
idx =  insidepoly(X(:),Y(:),S(k).X,S(k).Y);
   hold on
 plot(X(idx), Y(idx), 'r*')

Yet, I am trying to make same plot with respect to intensity of data value. I need to plot the value(1-100) of data with unique colour , something like jet(256) e.t.c. Looking for guidelines in this regard.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.