# Glitch in Filling?

Bug introduced in 8.0 and persisting through 12.0 or later

I ran into a problem while plotting and I was able to narrow it to this. Before I start "spelunking" I'd like to know if I am overlooking something or if this is a problem others have worked through.

Here is my data:

x = {{20, 15.3, 11.9, 8.8}, {16.5, 12.5, 9.2, 6.5}, {10.5, 8.5}};


I create a plot with filling between the two complete lines and it works as expected:

ListLogPlot[x, Joined -> True, PlotRange -> {{1, 4}, All},
Filling -> {
1 -> {{2}, Brown}
}
]


However when I add filling between the second line and the third (incomplete) one it breaks:

ListLogPlot[x, Joined -> True, PlotRange -> {{1, 4}, All},
Filling -> {
1 -> {{2}, Brown},
2 -> {{3}, Gray}
}
]


I was expecting:

• It arises from ListPlot, which ListLogPlot calls. That's as far as I could go, which perhaps you have already discovered. Does not happen with x = {Range[5, 2, -1], Range[4, 1, -1], Range[3, 2, -1]}, but it does happen with x = {0, 1, 2} + 2 {Range[5, 2, -1], Range[4, 1, -1], Range[3, 2, -1]}. A clue for a developer, I suppose. Nov 7, 2014 at 3:09
• Seems to be related to the last point of the first line being lower than the second to last point of the second curve. Try this Manipulate[ ListLinePlot[{{10, 10, a}, {b, b, 0}, {0, 0}}, Filling -> {1 -> {{2}, Brown}, 2 -> {{3}, Gray}}, PlotRange -> {{1, 3}, {0, 11}}], {{a, 7}, 0, 10}, {{b, 5}, 1, 9}] Nov 7, 2014 at 11:26
• @SimonWoods Looks like you nailed it. Would you be so kind as to submit that example to support for me? Nov 8, 2014 at 15:22
• Bug report now sent Nov 11, 2014 at 11:18
• The bug is still there in 10.0.2. Dec 11, 2014 at 19:44

Changing the order of lists restore the filling

x = {{10.5, 8.5}, {20, 15.3, 11.9, 8.8}, {16.5, 12.5, 9.2, 6.5}};

ListLogPlot[x, Joined -> True, PlotRange -> {{1, 5}, All},
Filling -> {1 -> {{3}, Brown}, 2 -> {{3}, Gray}}]


• This does work in v10.0.1. (+1) Any idea what's going on? As far as I could tell from Trace the Polygon sprang fully formed from the head of Zeus. Nov 6, 2014 at 11:48
• @Mr.Wizard Unfortunately, I don't know. Obviously, it is a bug in filling (choice of points for polygons is corrupted). Nov 6, 2014 at 21:48

Reversing the list in the Filling option makes it work (Mmav9):

ListLogPlot[x, Joined -> True, PlotRange -> {{1, 4}, All},
Filling -> {2 -> {{3}, Gray}, 1 -> {{2}, Brown}}]


Probably a bug :)

Works also with more series, apparently without problems:

x = {{20, 15.3, 11.9, 8.8}, {16.5, 12.5, 9.2, 6.5}, {10.5, 8.5}, {25, 22, 15}};
ListLogPlot[x, Joined -> True, PlotRange -> {{1, 4}, All},
Filling -> {1 -> {{4}, Blue}, 2 -> {{3}, Gray}, 1 -> {{2}, Brown}}]


• Unfortunately neither form shown works in v10. The first looks like i.sstatic.net/i93iP.png while the second does not show the brown filling. Bug, I guess. :-/ Nov 6, 2014 at 3:04
• @Mr.Wizard The really strange thing is that your original "bug" does show up in V9, while my rearranged list works. They bugged the walkaround :) Nov 6, 2014 at 3:23

The problem applies also to ListPlot and is related to the fact that all the datasets have exactly identical abscissas of the second point (which is the last point of the bottom line). To demonstrate this, at first I add the explicit abscissas into the dataset (the same bug persists):

x = {{20, 15.3, 11.9, 8.8}, {16.5, 12.5, 9.2, 6.5}, {10.5, 8.5}};
x = MapIndexed[{#2[[1]], Log@#1} &, #] & /@ x;
ListPlot[x, Joined -> True, Filling -> {1 -> {{2}, Brown}, 2 -> {{3}, Gray}}]


Now I perturb the abscissa of the second point in the first list:

x[[1, 2, 1]] += 2 $MachineEpsilon; ListPlot[x, Joined -> True, Filling -> {1 -> {{2}, Brown}, 2 -> {{3}, Gray}}]  The same result can be achieved by perturbing the second point in any other list. Now if I add third point to the last line, the bug appears again: AppendTo[x[[-1]], {3, 2}] ListPlot[x, Joined -> True, Filling -> {1 -> {{2}, Brown}, 2 -> {{3}, Gray}}]  And the remedy is the same, we should perturb the third point in any line: x[[1, 3, 1]] += 2$MachineEpsilon;
ListPlot[x, Joined -> True, Filling -> {1 -> {{2}, Brown}, 2 -> {{3}, Gray}}]