Question: I am preparing a figure for an article, and I would like very much to be able to fill a curve, but not under it, but to the vertical axis, i.e. to the left. Due to the meaning of the data I present, I cannot exchange the axes.

Here is a minimal example:

```
Plot[ArcCot[x], {x, 0, 1}, PlotRange -> {{0, 1.1}, {0.5, 2}}, AxesLabel -> {x, y}]

```

Can anyone think of a way of filling the curve to the`y` axis? I find no mention of this kind of filling in the standard documentation.

Answer: 
A somewhat roundabout way (switch x,y; fill; switch x,y again):

```
With[{plot = Plot[ArcCot[x], {x, 0, 1}, PlotRange -> {{0, 1.1}, {0.5, 2}}, 
    AxesLabel -> {x, y}]},
 With[{pts = Cases[plot,
                   Line[p_] :> (p /. {x_Real, y_Real} :> {y, x}), 
                   Infinity]},
  Show[
   ListLinePlot[pts, Filling -> Axis] /. {x_Real, y_Real} :> {y, x}, 
   FilterRules[Options[plot], Options[Graphics]]]
  ]]

```

![Mathematica graphics](https://i.stack.imgur.com/JTU9o.png)

One advantage to this roundabout way is filling to the axis `x = 0` when the `Plot` domain does not include it. Here we change the plot domain to `{x, 0.5, 2}`:

```
With[{plot = Plot[ArcCot[x], {x, 0.5, 2},
                  PlotRange -> {{0, 2.1}, {0., 2}}, AxesLabel -> {x, y}]},
 With[{pts = Cases[plot,
                   Line[p_] :> (p /. {x_Real, y_Real} :> {y, x}),
                   Infinity]},
  Show[
   ListLinePlot[pts, Filling -> Axis, AxesOrigin -> {0, 0},
     FilterRules[Options[plot], Cases[Options[ListLinePlot], Except[PlotRange -> _]]],
     Options[plot, PlotRange] /. {rx_List, ry_List} :> {rx, ry}] /.
       {x_Real, y_Real} :> {y, x},
   Options[plot, PlotRange]]
  ]]

```

![Mathematica graphics](https://i.stack.imgur.com/IzX4Y.png)

If placing the `y` axis to the right is desired, then the `AxesOrigin` can be used with `ListLinePlot` (when the coordinates are switched). Something like this:

```
Clear[x, y];
With[{plot = Plot[ArcCot[x], {x, 0.5, 2},
    PlotRange -> {{0.4, 2.1}, {0., 2}}, AxesLabel -> {x, y}]},
 With[{pts = Cases[plot,
                   Line[p_] :> (p /. {x_Real, y_Real} :> {y, x}),
                   Infinity]},
  Show[ListLinePlot[pts, Filling -> Axis, Frame -> True, AxesOrigin -> {0, 2.1},
     FilterRules[Options[plot], Cases[Options[ListLinePlot], Except[PlotRange -> _]]],
     Options[plot, 
       PlotRange] /. {rx_List, ry_List} :> {rx, ry}] /. {x_Real, y_Real} :> {y, x},
   Options[plot, PlotRange]]
  ]]

```

![Mathematica graphics](https://i.stack.imgur.com/mpmaq.png)
I know this thread is long time inactive, but **Michael E2**'s excellent fillVertical function above helped me out a lot. I did need a more "density"-like fill, so I'm sharing my variant of it (using my novice-level Mathematica programming skills) which splits the Line into monotonic segments:

```
fillVertical2[plot_, x0_: 0.] := plot /. Line[p_] :>
  Function[{mp},{{Opacity[0.2],
      Polygon[mp ~Join~ {{N@x0, mp[[-1, 2]]}, {N@x0, mp[[1, 2]]}}]}, Line[mp]}] /@ 
  SequenceCases[p, lp_ /; Less @@ lp[[All, 2]] || Greater @@ lp[[All, 2]]];

```

This gives a plot like

```
fillVertical2[Plot[Sin[x] + 0.3 x, {x, 0, 10}, PlotStyle -> Red]]

```

[![overlayed fillVertical](https://i.stack.imgur.com/4RZvD.png)](https://i.stack.imgur.com/4RZvD.png)