MATLAB Answers

Is this a bug in bar plot

5 views (last 30 days)
Durga Lal Shrestha
Durga Lal Shrestha on 22 Apr 2020
Commented: dpb on 23 Apr 2020
Something is not right with bar plot when some values are very very high and it is required to limit y values so that other values can be seen.
highValue=10E15;
y = [2 2 3*highValue; 2 5 6*highValue; 2 8 9*highValue; 2 11 12*highValue];
bar(y)
Now I want to limit yvalue so that I can see other values
ylim([0 10])
Now the results is:
No issue when highValue=10E14. Is this a bug in bar plot?

  4 Comments

Show 1 older comment
Durga Lal Shrestha
Durga Lal Shrestha on 22 Apr 2020
I tested with 2019a, 2019b and 2020a, the issue persistent with all these versions.
dpb
dpb on 22 Apr 2020
R2014b doesn't go outside the box boundaries but generates the same diagonal slash on the second group...
Adam Danz
Adam Danz on 22 Apr 2020
Error reproduced in r2020a.

Sign in to comment.

Answers (1)

Muhammad Usman
Muhammad Usman on 22 Apr 2020
I suggest you to use two additional lines of code
highValue=10E15;
y = [2 2 3*highValue; 2 5 6*highValue; 2 8 9*highValue; 2 11 12*highValue];
bar(y)
set(gca,'YScale','log');
grid on;

  4 Comments

Show 1 older comment
Durga Lal Shrestha
Durga Lal Shrestha on 22 Apr 2020
Thanks for the suggestion. But my data has also negative values, so log scale does not work.
Durga Lal Shrestha
Durga Lal Shrestha on 22 Apr 2020
I found this type of issue with plot function as well.
dpb
dpb on 23 Apr 2020
Is there really some mandatory reason to have such a large highvalue value, anyway, in reality?
Doesn't seem realistic use case, somehow...

Sign in to comment.

Tags