# How to get negative values of function on Y axis , when i am plotting as LogPlot [duplicate]

This might be trivial, but I am not able to get it. I am just keeping it simple.

Suppose I want to plot:

Plot[-x, {x, -1, 2}, Frame -> True]


Next if I want log scale on the Y axis, I am not getting the plot from -2 to 2, which is the range. I want to show those points in the plot, where the function is also negative. I know that Log[-quantity] is an imaginary number. Does it mean that when we have a minus value for the function, we can't use LogPlot?

LogPlot[x, {x, -2, 2}, Frame -> True]


How to get the -2 to 0 range of the function, in this case?

• Huh?!? How do you plot -x and instead show a plot of +x?!? Aug 21, 2021 at 19:10

You can either plot the logarithm of the absolute value:

LogPlot[Abs[x], {x, -2, 2}]


or use a symmetric logarithmic scale (symlog):

symlog = {
Function[x, Sign[x]*Log[Abs[x] + 1]],
Function[y, Sign[y]*(Exp[Abs[y]] - 1)]};

Plot[x, {x, -200, 200}, ScalingFunctions -> symlog,
Ticks -> {Automatic, Flatten@Table[{10 ^i, -10 ^i}, {i, 0, 2}]}]


LogPlot[{x, -x}, {x, -2, 2}, Frame -> True]


I was expecting ReImPlot would handle ScalingFunctions to give the desired result, but the documentation for ReImPlot under Possible Issues says:

ScalingFunctions applies to the real and imaginary parts.


So perhaps, something like this?

ReImPlot[Log[x], {x, -2, 2}, Frame -> True,
FrameTicks -> {{Quiet[
ChartingScaledTicks[{Log, Exp}][#1, #2, {6, 6}]] &,
ChartingScaledFrameTicks[{Log, Exp}]}, {Automatic, Automatic}}]