How to "imagesc" with logarithmic axis
이전 댓글 표시
Gurus,
I need to plot an image (named apple for example) with both x and y in logarithmic values. Below the the code example. It doesn't work....
*****************************************************************
x = 10.^linspace(log10(0.1),log10(3),10);
y = 10.^linspace(log10(1),log10(5),8);
apple = (y'*x/10);
imagesc(x,y,apple)
set(gca,'YScale','log','YMinorTick','on','Ydir','normal')
axis tight
set(gca,'XTick',([0.1,0.3, 1,3]))
set(gca,'YTick',([1 1.5 1.8 2.1 5]))
% codes below won't work, please help.!.
set(gca,'XScale','log')
set(gca,'XMinorTick','on')
set(gca,'YScale','log')
set(gca,'YMinorTick','on')
*****************************************************************
Best Regards,
Rebecca
답변 (5개)
Walter Roberson
2012년 6월 18일
0 개 추천
Do you want the image to appear log-compressed, or do you want the image to look normal even though the axes are log scale?
The x and y coordinates you provide for imagesc() are data coordinates that are used to linearly interpolate pixel positions. You can use a large coordinate range, but it is going to use linear interpolation over whatever range you use. If you have a normal (linear) image and set the axes to log then the image will get log-compressed (if it is rendered at all.)
If you need a normal-looking image on an axes that is log scale, then the easiest way would be to put a second axes at the same location, with its Visible property set off, and put the normal image on that linear axes. But be careful with ginput() or datacursors possibly not having the value you expect when the cursor is over the linear image; it might be appropriate to turn the image hittest off.
Rebecca
2012년 6월 18일
0 개 추천
댓글 수: 1
Walter Roberson
2012년 6월 18일
I will have to experiment with this. Could you upload a copy of your image?
http://www.mathworks.com/matlabcentral/answers/7924-where-can-i-upload-images-and-files-for-use-on-matlab-answers
Paul
2013년 5월 23일
0 개 추천
Hey Rebecca, Ben figured this one out. -Paul
Constantino
2018년 11월 2일
I have a similar problem. Please realize i don't have an "image", but instead, I just want to make a quick image from a "rows x columns" matrix, where the Y axis must be plotted in log scale. I thought it would be simple, but it seems matlab has so much complexity that my approach is not working.
image(My2DMatrix,'CDataMapping','scaled')
works fine. I can change the color scale, axes ranges, and everything through the menus from the created image. However, transforming the image so it displays a log Y axis does nothing to the image. Pixels are still squares of equal size (I think that is the key around my issue). Maybe I need another type of plot? I'm a complete newbe in matlab. Have worked with other languages but it seems matlab is not so easy as other programming environments.
댓글 수: 1
Walter Roberson
2018년 11월 2일
Try warp()
However nothing can change the fact that pixels in the display are rectangular, so if you have a wide range of data, the pixels more towards 0 are going to be overrepresented on the display.
Constantino
2018년 11월 2일
0 개 추천
Ok, I solved my problem using contourf, which handles better my type of data
카테고리
도움말 센터 및 File Exchange에서 Image Transforms에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!