image(x,y,A) fails on log axis depending on axis's limits
5 次查看(过去 30 天)
显示 更早的评论
Hi The question is pretty much self explanatory given the following example
The following code works:
figure
A = rand(200,200,3);
axes('XScale','log','YScale','log')
hold on
image([1e1 1e2],[1e2 1e4],A)
The following code doesn't work:
figure
A = rand(200,200,3);
axes('XScale','log','YScale','log')
hold on
image([1e1 1e2],[1e2 1e5],A)
The only difference between the two codes is the y coordinate of the top corner (1e4 in the first example, 1e5 in the second).
Why does this happen and how can I fix it?
3 个评论
采纳的回答
更多回答(1 个)
Walter Roberson
2018-4-9
XData and YData are locations of pixel centers. You have to use the upper and lower values and the resolution to calculate where the lowest edge of the pixel would be. If it would be 0 or negative then the image cannot be displayed on a log plot.
7 个评论
Walter Roberson
2018-4-10
What I had observed in the past was that MATLAB continues to use the linear formula for the purpose of prediction of whether to draw the image or not, but that once it comes to draw the image, it just draws it linearly as if log axes were not in effect. I did not check this out in detail, though.
Years ago I posted,
"When the fixed half pixel outside margin is translated to coordinates in log space, the result can be outside of the current XLim. When that happens, the image is largely clipped out. If you set the XLim manually and then adjust the XData to be close to but not quite at the XLim, the image will occupy most of the plot space, disappearing if the margin would project over the XLim."
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!