Base-2 logarithmic scale on bar diagram
    조회 수: 24 (최근 30일)
  
       이전 댓글 표시
    
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
      
      
 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
      
      
 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
추가 답변 (0개)
참고 항목
카테고리
				Help Center 및 File Exchange에서 Log Plots에 대해 자세히 알아보기
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!




