image(x,y,A) fails on log axis depending on axis's limits
8 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Luca Amerio
le 9 Avr 2018
Commenté : Walter Roberson
le 17 Avr 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 commentaires
Réponse acceptée
Plus de réponses (1)
Walter Roberson
le 9 Avr 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 commentaires
Walter Roberson
le 10 Avr 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."
Voir également
Catégories
En savoir plus sur Graphics Object Properties dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!