# 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'})
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