How do I plot an image in Log-Log axis?

5 vues (au cours des 30 derniers jours)
Tomas Carvalho
Tomas Carvalho le 15 Sep 2022
Commenté : dpb le 16 Sep 2022
What I want to do is the following: a log-log plot, with areas corresponding to certain categories of flow. Ideally, it would look like the this figure, but with shaded areas.
Currently I am able to determine for each pair of values of x and y, what type of flow it corresponds to. However, I can't plot it over a log-log axis. What I'm gettin looks like this:
The code i'm using is this:
usg=logspace(-1,log10(500),1000); %[m/s]
usl=logspace(-2,log10(50),1000); %[m/s]
P=findcategory(usl,usg)
figure
h = imagesc(X,Y,P);
h.CDataMapping='direct';
axis xy
where P is a matrix with values from 1 to 8 ( flow categories), where each element is calculated using a pair of elements of usg and usl.
How can I plot this P matrix, in a log-log plot, instead of a linear axis?

Réponse acceptée

dpb
dpb le 15 Sep 2022
...
h = imagesc(usl,usg,P);
hAx=gca;
set(hAx,{'XScale','YScale'},{'log','log'})
  2 commentaires
Tomas Carvalho
Tomas Carvalho le 16 Sep 2022
Hey,
Thanks, it worked! I was getting some things mixed up in my head, but then I figured it out. I first thought your solution would create another problem, but I was wrong. It is simple and effective. :)
dpb
dpb le 16 Sep 2022
Kewl!

Connectez-vous pour commenter.

Plus de réponses (1)

William Rose
William Rose le 15 Sep 2022
I canot run your code since I do not have findcategory(). I made usg and usl slightly different lengths to be sure that I my surf plot was oriented the right way. Otherwise it is possible to reverse the x and y coordinates in the plot, without knowing it. I set the edgecolor to none in the surface plot, since if you don't, the black edges will dominate the surface.
usg=logspace(-1,log10(500),101); %[m/s]
usl=logspace(-2,log10(50),100); %[m/s]
for i=1:length(usg), for j=1:length(usl)
P(i,j)=floor(log10(usg(i))+log10(usl(j)))+3;
end, end
lusg=log10(usg);
lusl=log10(usl);
figure
surf(lusl,lusg,P,'EdgeColor','none');
view(0,90)
xlabel('log_{10} usl'); ylabel('log_{10} usg');
colorbar
Try that. It is a start. You still have to get the right labels on the color bar...
  1 commentaire
Tomas Carvalho
Tomas Carvalho le 16 Sep 2022
Hello,
Your solution would also work! However I prefer to keep the logaritmic scale displayed in the traditional way.
Thank you anyway.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Log Plots dans Help Center et File Exchange

Produits


Version

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by