Search code examples
matlabmatlab-figurelatitude-longitude

Error in longitude contour near the pole MATLAB


I want to plot lat/lon contours at the south pole, my data consists of grid cells, each with a lat and lon value. My problem is where the longitudes "meets" each other, as you can see in the picture, the vertical longitude in the lower part of the picture have a lot of lines on top of each other.lat/lon contours Does anyone know how to remove them? Here is my code:

coldiv = -57.5:2.5:-7.5; 
min_pr = coldiv(1); max_pr = coldiv(end);
cmap = [0 0 0.4; 0 0 0.7; 0 0 1; 0 0.2 1; 0 0.4 1; 0 0.6 1; 0 0.8 1; 0 1 1;         
0 1 0; 0.6 0.8 0; 0.6 0.6 0; 0.6 0.4 0; 0.6 0.2 0; 1 0 0];


x = linspace(1,length(coldiv)-2,length(cmap));
xi = 1:length(coldiv)-2;
cmap = interp1(x,cmap,xi);
cmap = [0. 0. 0.; cmap];
fig=figure();
set(fig, 'Position', [10 10 1500 700])


pcolor(mean(tas_ann_DMI_hist_tot,3))
shading flat
hold on;
contour(flip_lat_DMI, 'k','ShowText','on');
contour(flip_lon_DMI, 'k','ShowText','on');
caxis([min_pr max_pr]);colormap(cmap);
axesHandles = findobj(get(fig,'Children'), 'flat','Type','axes');
axis(axesHandles,'square')
set(gca,'YTick',[]);
set(gca,'XTick',[]);

Solution

  • I found a solution.

    flip_lon_DMI(flip_lon_DMI<-160) = NaN;
    flip_lon_DMI(flip_lon_DMI>190) = NaN;
    
    ...
    
    contour(flip_lat_DMI,-90:5:-60,'k--','ShowText','on','Color',[.5 .5 .5]);
    contour(flip_lon_DMI,-150:30:180,'k--','ShowText','on','Color',[.5 .5 .5]);