How to "imagesc" with logarithmic axis
220 ビュー (過去 30 日間)
古いコメントを表示
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
0 件のコメント
回答 (5 件)
Walter Roberson
2012 年 6 月 18 日
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.
0 件のコメント
Rebecca
2012 年 6 月 18 日
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
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 日
Ok, I solved my problem using contourf, which handles better my type of data
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Lighting, Transparency, and Shading についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!