Base-2 logarithmic scale on bar diagram

조회 수: 24 (최근 30일)
D12
D12 2022년 11월 16일
댓글: dpb 2022년 11월 16일
Hello,
I would like to plot a bar diagram but with a base-2 logarithmic scale on y-axis. Is it possible to have a logarithmic scale with the bar function ? Can someone help me ?
Here is an example of a diagram with a linear scale on which I would like to use a base-2 logarithmic scale on y-axis
figure;
set(gcf,'color','w');
x=[1 2 3 4];
y= [3 0.76 .82
4.2 1.1 0.9
2.5 0.75 0.85
0.8 0.9 3.5];
b= bar (x,y,1);
  댓글 수: 1
dpb
dpb 2022년 11월 16일
What, specifically, is the expected result to look like? Since
log2(y)=log10(y)/log10(2)
by definition, it's a linear scaling so just using
...
hB=bar(x,y,1);
hAx=gca; hAx.YScale='log';
will produce the same relative bar heights as those if you were to mess around with the log2() values and scale them.

댓글을 달려면 로그인하십시오.

채택된 답변

David Hill
David Hill 2022년 11월 16일
A logarithmic scale does not matter what the base is. You can change the markers to whatever you want (powers of two).
figure;
set(gcf,'color','w');
x=[1 2 3 4];
y= [3 0.76 .82
4.2 1.1 0.9
2.5 0.75 0.85
0.8 0.9 3.5];
b= bar (x,y,1);
set(gca, 'YScale', 'log')

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Log Plots에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by