MATLAB: How to plot negative value with log scale

logplot

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?

Best Answer

Rather than use the transform you mentioned in your comment,
t = sign(x)*log(abs(x))
you could use
t = sign(x)*log(1+abs(x)/10^C)
which would preserve the continuity of your plot across zero and allows you to tune the visibility into values near zero. As long as you are careful to label the axes appropriately I don't think it is fair to call this incorrect or deceptive.
You can edit the Tick marks and labels and even modify the MinorTicks of the [X,Y,Z]Ruler object as occurs when you use set(gca,'XScale','log') or the like.
Inspired by your question, I made a function called symlog to do just this and put it on the File Exchange here.
An example plot:
x = linspace(-50,50,1e4+1);
y1 = x;
y2 = sin(x);
y3 = x - sin(x);
plot(x,y1,x,y2,x,y3)
symlog(gca,'xy',-1.7)