Why does this happen when using the log scale for the y-axis?

Hello,
I am trying to build a bar chart and to neatly represent the errors for both, the methods of Lagrange and linear spline, for interpolation.
however whenever I run the code, I am getting bars that tend to infinty from below.
I want them to start from so that error bars higher than that go up, and error bars lower than that go down.
How can I solve this problem?
Thank you for your help.
figure
L_err_X = [5.58766454362922 21.1118153882187 15.7457248117304 9056.59448225290 737241807.345839]
L_err_X = 1×5
1.0e+08 * 0.0000 0.0000 0.0000 0.0001 7.3724
S_err_X = [5.58766454362922 15.9092058567649 9.79528785926242 1.18154028820416 0.481370143021060]
S_err_X = 1×5
5.5877 15.9092 9.7953 1.1815 0.4814
bar([L_err_X; S_err_X]')
legend('lagrange','Spline')
title('Erreurs de Calcul pour les 2 Methodes')
ylabel('error X')
set(gca,'YScale','log')
grid on

2 Comments

What exactly do you consider as "problem" here? One bar reaches the height of 7.3e8 and it is displayed accordingly. Everything looks as expected. So what do you want to "solve"?
Hello,
Thank you for your reply.
Here's the problem. the fact that the bars extend from below to . This figure is the same one but zoomed out.

Sign in to comment.

 Accepted Answer

Setting the BaseValue parameter to a positive value is an option.
All the bar heights appear to be positive.

2 Comments

Thank you for putting the effort to understand my problem. After setting the basevalue to 1, it worked.
Thank you again.
Here is the code:
figure
L_err_X = [5.58766454362922 21.1118153882187 15.7457248117304 9056.59448225290 737241807.345839];
S_err_X = [5.58766454362922 15.9092058567649 9.79528785926242 1.18154028820416 0.481370143021060];
b = bar([L_err_X; S_err_X]');
b(1).BaseValue = 1;
legend('lagrange','Spline')
title('Erreurs de Calcul pour les 2 Methodes')
ylabel('error X')
set(gca,'YScale','log')
grid on

Sign in to comment.

More Answers (0)

Categories

Products

Release

R2022b

Community Treasure Hunt

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

Start Hunting!