Base-2 logarithmic scale on bar diagram
24 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
D12
el 16 de Nov. de 2022
Comentada: dpb
el 16 de Nov. de 2022
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 comentario
dpb
el 16 de Nov. de 2022
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.
Respuesta aceptada
David Hill
el 16 de Nov. de 2022
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 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Log Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

