The logarithm of a negative value is not defined in the real space.
But in practical applications, we occasionally see that the magnitude of the data changes exponentially even in the negative area. How can we present such data in a graph? For example in Fig.1, you see the sample curve in linear scale where the curve changes exponentially in both positive and negative directions separately.
1) y’=Log(y) : If you simply plot the data in log scale, you obviously cannot visualize the data in the negative range as in Fig. 2. Of course, this approach is okay if data stays only within the positive region.
2) y’ = sign(y)*Log(|y|): You may first think that it’s a good idea, but when the original y value goes smaller that 1, a problem occurs – if the value is negative, the output of this function (y’) becomes positive, though when the value is positive, the output becomes negative! E.g.
sign(-0.0001)*Log(|-0.0001|) = 4
sign(0.0001)*Log(|0.0001|) = -4
See Fig. 3. We should avoid this method unless the absolute value of the data never enters less than 1.
3) y’ = sign(y)*log(1 + |y| ): This formula is so-called Log-Modulus transformation. This method actually resolves the above discontinuity problem in 2), and when uphill or downhill of the original data and the converted data change synchronically. However, the biggest problem of this method is that the converted data cannot no longer depict the exponential trend as a straight line. See Fig. 4. Similar to 2), this method should be avoided unless the absolute value of the data never goes less than 1.
4) y’ = log(|y|) in separate positive/negative regions:
To overcome the drawbacks of above three methods,
we can separately plot negative data as log(|x|) flipped in the third/forth quadrant. To realize this approach in Origin, there are two methods to implement. One method is to set up multiple layers for negative side and positive side separately. Please see Fig. 5. Layer1 is used for positive region and layer2 is used for negative region. The range between the plus/minus minimum values around zero (in this sample, ±10E-4) is actually an infinitely wide gap with no data like an “abyss”. (The third layer was created to present only 0 data.)
The other method is to normalize the data
by dividing by the minimum value so that the log of the minimum value shift to the zero position without changing the shape of the curve. This method can plot the data in a single layer. As you see in Fig. 6, the abyss zone of ±10E-4 is presented as a horizontal grey belt.
In either Fig. 5 or Fig. 6, you can clearly recognize visually the exponential tendencies of both the positive part and in this sample, the negative part are the same in magnitude as their slopes are visually indicated equal in the graph.
To create a graph like Fig.5 or Fig. 6, I have made a sample file so that you can try by yourself. Follow the steps below to try them out:
1) Download this project file. If you unzip the file, and open it by Origin, then you find the following two folders in the Project Explorer:
– Multi-Layer presentation
– Single Layer presentation
2) You can use the empty worksheet in either folder as a template. You can enter your XY data into the first and second columns, then the necessary calculation will be proceeded automatically, and the result embedded graph will appear in the top cell in the last column. You can double-click this embedded graph to expand it, and press the Rescale button at the top right corner of the graph to adjust the scale. (You can duplicate the expanded graph window, if you want to make an independent graph.)
Fig. 7 below shows another example to demonstrates an exponentially modulated sine curve as in the left figure. The middle figure is a plot of this data visualized in multiple layers, and the right figure is the one in a single layer.
Note: Choosing either the multi-layer version or the single layer version, the following two criteria may help to decide: 1) In the multi-layer format, the plot line cannot be connected crossing the “abyss”, but it can do in the single layer template. 2) The multi-layer’s ticks and tick labels are of the “native” log scale, and you can customize in the Origin’s usual way. In contrast, ticks and tick labels in the single layer template are a converted presentation from the linear scale, and are not flexibly customizable.