As I continue to deal with chemical kinetics, I was in a position in which I wanted to plot both negative and positive values on a logarithmic scale.

Why? I was looking at Rate of Production (ROP) analysis, where species can be produced and consumed. Do to the large range of magnitudes involved in chemical kinetics, a conventional linear scale is impractical when trying to plot the results.

Because a coventional plot does not work, we need to rething how exactly we plot the data. However once thought through, the idea is simple - the implementation, so so (because values are counterintuitive).

Let me lay out the process:

- The positive region (y-axis) of the plot is reserved for positive values, the negative region (y-axis) is reserved for the negative values. Thus, our x-axis, where y=0 must be our "zero point".
- Because a log plot continues indefinitely with smaller values, we have to define a cut-off at which we consider the value to be zero. E.g. "-20" as log10(1e-20)=-20 and -20 is pretty much insignificant (though this is relative, it may be singificant if other values are of a similar magnitude).
- With the cut-off defined, we filter the values as greater than zero or less than zero and keep them seperately. If the value is less than zero, we flip the sign before applying the log10 calculation. Where a value is zero we apply out minimum.
- We now have two datasets that go from value ymin to ymax.

So we add ymin, to align the minimum value with the x-axis at y=0

Thus we obtain a logarithmic plot in the positive region of the y-axis. And the negatives? We now apply a minus sign to plot the curve in the negative region of the y-axis. - Add in some custom labels on the y-axis to display the correct magnitude, and we have obtained a logarithmic plot that covers both negative (e.g. consumption) as well as positive (e.g. production) values.

The script is available on GitHub at https://github.com/DetlevCM/some-R-Scripts/tree/master/plotting-negativ…

And for those interested - and example plot, y = (x/10)^3: