How can I plot negative value with log scale?
Show older comments

I want plot some data which varies over many order (from 1e6 to 1e-4) with some positive and negative values in log scale(like the attached picture), but the matlab function -- 'loglog' can only plot either positive or negative data in one drawing. Is there any function can plot both the positive and negative data? just like the 'symlog' scale in matplotlib. Or any other alternative way?
5 Comments
dpb
on 27 Jun 2016
Attach your desired plot(*)...not sure what negative values in log space are???
(*) Yeah, the interface is funky, you have to "Attach" the figure also after you've selected it from the file dialog...
Qing-quan Zhi
on 28 Jun 2016
Edited: Qing-quan Zhi
on 28 Jun 2016
dpb
on 28 Jun 2016
That's a pretty funky scale as well as the interface... :)
The range from 10^-2 to 0 is same as that from 10^-2 to 10^0 (two decades) although log(0) --> -Inf.
What one could do, I suppose, is have two axes, one with normal and other reversed y-axes directions and then fix up the middle y tick label with the introduction of the fake zero and and the minus signs that can't ever be in log space. The lower half axes would have to use the abs(y) in the semilogy call, of course.
Qing-quan Zhi
on 28 Jun 2016
dpb
on 28 Jun 2016
Yeah, but...what do you do about the issue that the last decade covers range of infinite number of decades on the same scale as the previous that is actually only one? Truncate data to eliminate it or what???
Accepted Answer
More Answers (2)
the cyclist
on 28 Jun 2016
2 votes
This strikes me as an incorrect and potentially deceptive way to plot these data.
Instead, I think I would use the subplot function, putting the positive data in the upper subplot and the negative data into the lower subplot. Then, there would be a "chasm" between the two, which makes sense because they really are separated in log space.
Granted that by default the two plots would take up some real estate on the page, but you can adjust properties to minimize the impact of that.
Rajen Biswa
on 15 Apr 2018
0 votes
I have these data: Ebbyno=[ -5 -3 -1 1 3 5 7 9 11 13 15}; already in dB. BER1= [ 0.3993 0.3769 0.3445 0.3015 0.2091 0 0 0 0 0 0 0 0]; how can i use the loglog plot to plot this data in matlab.
Categories
Find more on Log Plots 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!