pcolor/m_pcolor cannot create world map correctly
이전 댓글 표시
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
Ashish Gudla
2015년 5월 27일
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
2015년 5월 29일
Can you upload your lat,lon grids?
Rong Yu
2015년 6월 5일
Chad Greene
2015년 6월 8일
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
2015년 6월 8일
Chad Greene
2015년 6월 8일
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
2015년 6월 8일
Chad Greene
2015년 6월 9일
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
2015년 6월 9일
Mike Garrity
2015년 6월 9일
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
2015년 6월 9일
채택된 답변
추가 답변 (1개)
Chad Greene
2015년 6월 8일
0 개 추천
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?
카테고리
도움말 센터 및 File Exchange에서 Repeated Measures and MANOVA에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!