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

63 次查看(过去 30 天)
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?

采纳的回答

dpb
dpb 2022-9-15
...
h = imagesc(usl,usg,P);
hAx=gca;
set(hAx,{'XScale','YScale'},{'log','log'})
  2 个评论
Tomas Carvalho
Tomas Carvalho 2022-9-16
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. :)

请先登录,再进行评论。

更多回答(1 个)

William Rose
William Rose 2022-9-15
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 个评论
Tomas Carvalho
Tomas Carvalho 2022-9-16
Hello,
Your solution would also work! However I prefer to keep the logaritmic scale displayed in the traditional way.
Thank you anyway.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Surface and Mesh Plots 的更多信息

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by