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

19 views (last 30 days)
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?

Accepted Answer

dpb
dpb on 15 Sep 2022
...
h = imagesc(usl,usg,P);
hAx=gca;
set(hAx,{'XScale','YScale'},{'log','log'})
  2 Comments

Sign in to comment.

More Answers (1)

William Rose
William Rose on 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 Comment
Tomas Carvalho
Tomas Carvalho on 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.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!