# ScalingFunctions->Reverse in ListPlot not compatible with Epilog

My question is rather to the point; I'm trying to reverse the x-axis on a ListPlot that has some objects drawn in it with Epilog. I looked around a bit and I found that the easiest method is to use ScalingFunctions->Reverse, which indeed neatly reverses the x-axis, but somehow ends up making the Epilog disappear. Does anyone know why this happens/how I can fix this?

Some sample code to illustrate it:

xs = Table[i, {i, 0, 1, 0.1}];
ys = xs^2;
{ListPlot[Transpose[{xs, ys}],(*ScalingFunctions\[Rule]{"Reverse",
Identity},*)
Epilog -> {{Directive[{Thick, Black}],
Line[{{0.4, 0}, {0.4, 1}}]}}],
ListPlot[Transpose[{xs, ys}],
ScalingFunctions -> {"Reverse", Identity},
Epilog -> {{Directive[{Thick, Black}],
Line[{{0.4, 0}, {0.4, 1}}]}}]}


• the reverse has effectively negated the coordinate system so you need to make your line Line[{{-0.4, 0}, {-0.4, 1}}] (sorry more of a work around than an explanation) Commented Jan 20, 2017 at 18:32
• ScalingFunctions -> Reverse just renames the ticks. If you increased your PlotRange to still include the right side of the x-axis I'm sure you'd see your epilog call.
– ktm
Commented Jan 20, 2017 at 18:32
• @user6014 it does quite a bit more than that. It transforms the data, fixes the PlotRange, the AxesOrigin, and the ticks. Commented Jan 20, 2017 at 18:34

The Epilog has not disappeared, it just is not visible with the PlotRange generated by ListPlot, e.g.

In[23]:= Options[plot, {PlotRange, Epilog}]
(*Out[23]= {PlotRange -> {{-1., 0}, {0, 1.}},
Epilog -> {{Directive[{Thickness[Large], GrayLevel[0]}],
Line[{{0.4, 0}, {0.4, 1}}]}}}*)


where plot is the one with the ScalingFunctions. The difficulty here is that Epilog and Prolog exist in the Graphics coordinate system, not the coordinate system your data is in. The workaround is to transform the coordinates used to the data coordinates, i.e.

Epilog -> {{Directive[{Thickness[Large], GrayLevel[0]}],
Line[{{-0.4, 0}, {-0.4, 1}}]}}}


Similarly for the other ScalingFunctions, too.