Skewed Data when Scaling axis with imagesc()
조회 수: 10 (최근 30일)
이전 댓글 표시
When plotting 2D data I tend to default to using imagesc() due to its nice default behavior. However, I found myself very mislead with some plotted results when trying to scale the data in the axis. In the example below, I compare between pcolor() and imagesc() for scaled and unscaled y-axis data.
x=1:200;
y=1:100;
[X, Y] = meshgrid(x, y);
dummyData = (sqrt(X.^2 + Y.^2));
area = 2;
distance = 100;
nexttile
imagesc(x,y, dummyData);
set(gca,'YDir','normal')
title('Unscaled with imagesc()')
nexttile
p1=pcolor(x,y, dummyData);
p1.EdgeAlpha = .1;
title('Unscaled with pcolor()')
nexttile
imagesc(x, atand(sqrt(area./y)./distance), dummyData);
set(gca,'YDir','normal')
title('y-axis scaled with imagesc()')
nexttile
p2=pcolor(x, atand(sqrt(area./y)./distance), dummyData);
p2.EdgeAlpha = .1;
title('y-axis scaled with pcolor()')
The unscaled look identical, great!
But the scaled are not. The pcolor is the expected result. Notice how the light EdgeAlpha of the scaled pcolor() shows the streatching of the grid to accound for the non-linear axis. Is there something I'm doing wrong with imagesc()? Or is this a limitation of imagesc() since it is expecting rectilinear grid data since it is intended for displaying images?
댓글 수: 0
채택된 답변
DGM
2022년 3월 10일
편집: DGM
2022년 3월 10일
When setting x and y inputs to imagesc() or image(), the entire x,y vectors are not used. Imagesc considers only the first and last values of x and y and creates a linear set of ticks between those values.
As to why that's the behavior, I think that the x, y parameters used by image/imagesc() are mostly intended just for placing the image within a uniform space, so they're basically just box coordinates.
A = imread('peppers.png');
B = imread('cameraman.tif');
imagesc(A); hold on
imagesc([100 300],[100 300],B)
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Graphics Performance에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!