How do I convert a linear scale array to a logarithmic without getting negative values?
Show older comments
Hi All
I need to plot ( bar plot) values, and on the X axis , I want to convert them to logarithmic, but the values <1 become negative. how to avoid and fix it ?
1 Comment
Rik
on 6 Jul 2020
You would have to remove those.
Answers (1)
madhan ravi
on 6 Jul 2020
0 votes
Replace < 1 with nan.
14 Comments
farzad
on 6 Jul 2020
f=barh(y, max(0,log(x)), 'basevalue', 0);
If you want to replace values, you will have to store the intermediate result, or write a function that does that.
farzad
on 7 Jul 2020
Rik
on 7 Jul 2020
You can change the axis if you like. What exactly do you want to happen?
farzad
on 7 Jul 2020
madhan ravi
on 7 Jul 2020
set(gca, 'XScale', 'log')
farzad
on 7 Jul 2020
Rik
on 7 Jul 2020
In X or Y?
farzad
on 7 Jul 2020
farzad
on 8 Jul 2020
farzad
on 9 Jul 2020
madhan ravi
on 9 Jul 2020
Nope
farzad
on 9 Jul 2020
farzad
on 9 Jul 2020
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!