Say that I want to reverse the x-axis of a plot, there are a few solutions on here (like those in the answers here and here) but most of them are valid only for a ListPlot
variant and not a Plot
variant.
The answer by MarcoB in the second link above uses the option ScalingFunctions
to achieve the goal and I was interested in how to apply it to a Plot
(or LogPlot
or LogLogPlot
, etc). It seems to work just fine in reversing the x-axis if the function being plotted is linear:
{Plot[2 (k - 2), {k, -5, 0}, PlotRange -> All],
Plot[2 (k - 2), {k, -5, 0},
ScalingFunctions -> {{-# &, -# &}, Identity}, PlotRange -> All]}
but it gives strange results when the function is nonlinear,
{Plot[2 (k - 2)^3, {k, -5, 0}, PlotRange -> All],
Plot[2 (k - 2)^3, {k, -5, 0},
ScalingFunctions -> {{-# &, -# &}, Identity}, PlotRange -> All]}
If I try the same thing on a ListPlot
it works just fine,
list = {#, 2 (# - 2)^3} & /@ Range[-5, 0, .1];
{ListPlot[list, PlotRange -> All],
ListPlot[list, ScalingFunctions -> {{-# &, -# &}, Identity},
PlotRange -> All]}
Is there a way to do this with ScalingFunctions
, or is it simply not supported and I need to use my own workaround?
Plot[0, {t, 0, 1}, ScalingFunctions -> {Identity, "Log"}]
puts the line aty == 1
when there should be no line. $\endgroup$