pcolor/m_pcolor cannot create world map correctly
Show older comments
Hello all,
I have an issue to create world mean temperature map correctly with pcolor/m_pcolor. There are strips on the map created. Please see the first map.
h1 = pcolor(lon,lat,statTa(:,:,i)); set(h1,'edgecolor','none'); colorbar;

When I use imagesc, it shows pretty well. Please see the second map. But I think I prefer to use pcolor/m_pcolor to create map since they are more powerful on creating maps. Please help me on what happened when I was using pcolor here. Thank you very much!
h2 = imagesc(lon,lat,statTa(:,:,i)); set(gca,'ydir','normal'); colorbar;

11 Comments
Ashish Gudla
on 27 May 2015
It might be possible that the lat,lon data is not uniform and pcolor is somehow trying to draw a line between non uniform grid while imagesc is not.
Is the data uniform? Also what version of MATLAB is this?
Chad Greene
on 29 May 2015
Can you upload your lat,lon grids?
Rong Yu
on 5 Jun 2015
Chad Greene
on 8 Jun 2015
I cannot reproduce the problem. It looks like your oceans are set to NaN, so I'm doing the same below. I resize the dataset before using my landmask function because landmask is quite slow for large grids.
load lonLat
% Created gridded lat/lon:
[long,latg] = meshgrid(lon,lat);
% Create temperature-like data:
T = 250+50*cosd(latg) + 5*sind(long) + rand(size(latg));
% Set oceans to NaN:
scale = 5;
ocean = ~landmask(imresize(latg,1/scale),imresize(long,1/scale));
T(imresize(ocean,scale)) = NaN;
% Plot with pcolor:
h1 = pcolor(lon,lat,T);
set(h1,'edgecolor','none');
colorbar

Rong Yu
on 8 Jun 2015
Chad Greene
on 8 Jun 2015
Very strange. It works just fine for me in R2012b.
load lonLat
load monthTa1
h1 = pcolor(lon,lat,monthTa1);
set(h1,'edgecolor','none')
colorbar;
colormap(brewermap(1024,'Reds'))
set(gca,'color',rgb('ocean blue'))
borders('countries','color',.2*[1 1 1],'nomap')

Above I used brewermap because the default jet colormap is a bit garish, and rgb to get ocean blue. National borders are plotted with borders
Have you tried gridding your lat/lon arrays? Syntax would be
[long,latg] = meshgrid(lon,lat);
pcolor(long,latg,Z)
Not sure if gridding your lat/lons will fix the problem, but give it a shot.
Rong Yu
on 8 Jun 2015
Chad Greene
on 9 Jun 2015
The .bmp amd the .fig both look good for me. To be clear, the map looks good on your machine after you save it, but not in the Matlab figure window? If this is the case, try switching renderers. Type
set(gcf,'renderer','opengl')
If that doesn't work, try
set(gcf,'renderer','painters')
and if that doesn't work, try
set(gcf,'renderer','zbuffer')
Rong Yu
on 9 Jun 2015
Mike Garrity
on 9 Jun 2015
What version of MATLAB are you using? That looks like an issue that was fixed in R2014b. Is your version older than that, or newer?
Rong Yu
on 9 Jun 2015
Accepted Answer
More Answers (1)
Chad Greene
on 8 Jun 2015
0 votes
I see that when you use pcolor your axis values are not lat,lon values. Looks like linear indices of rows and columns. Are you sure you're plotting lat and lon?
Categories
Find more on Repeated Measures and MANOVA 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!