Base-2 logarithmic scale on bar diagram
26 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaire
dpb
le 16 Nov 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.
Réponse acceptée
David Hill
le 16 Nov 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 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Log Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

