image(x,y,A) fails on log axis depending on axis's limits
5 views (last 30 days)
Show older comments
Luca Amerio
on 9 Apr 2018
Commented: Walter Roberson
on 17 Apr 2018
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 Comments
Accepted Answer
More Answers (1)
Walter Roberson
on 9 Apr 2018
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 Comments
Walter Roberson
on 10 Apr 2018
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."
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!