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

18 ビュー (過去 30 日間)
Tomas Carvalho 2022 年 9 月 15 日
コメント済み: dpb 2022 年 9 月 16 日
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 2022 年 9 月 15 日
...
h = imagesc(usl,usg,P);
hAx=gca;
set(hAx,{'XScale','YScale'},{'log','log'})
##### 2 件のコメント表示非表示 1 件の古いコメント
dpb 2022 年 9 月 16 日
Kewl!

サインインしてコメントする。

### その他の回答 (1 件)

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 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.

サインインしてコメントする。

### カテゴリ

Find more on Lighting, Transparency, and Shading in Help Center and File Exchange

R2021b

### Community Treasure Hunt

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

Start Hunting!

Translated by