pcolor and pixel shift
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
I am using the following code. It appears that my text '*' has been shifted somewhat. Any suggestions on how to shift it back. It is a known issue with pcolor I am just not sure how to deal with it. Thanks!
h = pcolor(x,y, cor_son_eurasia');hold on;axis xy;
shading flat
sz = size(lat_new);
prob_son_eurasia = prob_son_eurasia';
for i=1:sz(1)
for j=1:sz(2)
if prob_son_eurasia(i,j)==1
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
0 Commenti
Risposte (1)
Image Analyst
il 3 Lug 2012
What are you trying to do? Display an image? pcolor() is not good for displaying pixel images. You have one less "tile" than you have pixels in each direction. For example using pcolor on a 5 by 8 image will show an image with 4 by 7 little colored squares. What's more, they don't correspond to pixel values but to the slope of the sheet that would be warped between the corners. It's really the corners of the squares that have the values, not the squares themselves. And it's really the corners of the squares that have the coordinates, not the center of the squares themselves. So I believe that's why your text is displaced. Since it's so deceptive to use pcolor(), I recommend you use imshow() or image() instead.
0 Commenti
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!