the problem of shifting and pcolor
이전 댓글 표시
Hi all, I am doing this code, and it appears that my text pixels are shifted compared to my pcolor output. Any suggestions. Note, my data contains NaN so image() does not work. Also, x and y are both of matrix types, not vectors. Any suggestions would be really appreciated. THANKS!
m_proj('stereographic','lat',90,'radius',60, 'rotateangle',270)
[lat_new,lon_new] = ndgrid(lat,lon);
[x,y] = m_ll2xy(lon_new,lat_new);
h = pcolor(x,y, cor); hold on;axis xy;
shading flat
sz = size(lat_new);
for i=1:sz(1)
for j=1:sz(2)
if prob(i,j)==1
%THESE APPEAR TO BE SHIFTED:(((
g = text(x(i,j),y(i,j),'*');
set(g,'fontsize',[10]);
set(g,'fontweight','bold');
hold on;
%z = text(x(i,j),y(i,j),num2str(cor(i,j)));
end
end
end
답변 (2개)
Image Analyst
2012년 7월 4일
0 개 추천
Right. We talked about this before. Don't use pcolor. image() and imshow() have no problem handling images with nans in them - I actually tried and verified that. You just have to make sure x and y are in the range of 1 to sz(1) or sz(2)
댓글 수: 4
Image Analyst
2012년 7월 4일
편집: Image Analyst
2012년 7월 4일
I'm not sure why you still insist on pcolor. Let me illustrate. Run this demo:
fontSize = 22;
m =[...
2 1 3 1 3
3 1 3 3 1
2 2 3 2 1
3 1 2 1 1
2 1 1 1 1]
figure(1);
pcolor(m)
shading('Faceted');
title('Faceted', 'FontSize', fontSize);
figure(2);
pcolor(m);
shading('interp');
title('interp', 'FontSize', fontSize);
figure(3);
pcolor(m);
shading('flat');
title('flat', 'FontSize', fontSize);
Do you expect to see a picture of 5 by 5 "pixels" where all the "1" elements have the same color, and all the "2" elements have the same color (but different than the color for 1), and all the "3" elements have the same color (but different than the color for 1 and 2)? That would seem reasonable wouldn't it? Is that how it actually looks? The answer is NO. The 1's DON'T all have the same color and neither do the 2's and 3's. Moreover the picture only has 4 by 4 pixels, not 5 by 5. You're warned about this in the source code for pcolor: " the last row and column of C are not used" Is that what you want? Plus there's the problem you originally asked. So, given all that, plus the fact that I told you image() and imshow() both handle (ignore) nans, can you explain to me why you still want to use pcolor?
jenka
2012년 7월 4일
jenka
2012년 7월 4일
Image Analyst
2012년 7월 4일
I don't have those functions. If they're in the mapping toolbox, I don't have that. You can use a colormap to get rid of the blue, like
imshow(yourArray, []);
colormap(gray(256));
jenka
2012년 7월 4일
0 개 추천
댓글 수: 2
Walter Roberson
2012년 7월 4일
Yes, that is how it is designed, and is the reason not to use pcolor()
Chad Greene
2015년 5월 1일
Here's a depiction of some funny effects using pcolor.
카테고리
도움말 센터 및 File Exchange에서 Red에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!