15
$\begingroup$

Bug introduced in 8.0 and persisting through 11.0.1 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}
  }
]

enter image description here

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}
  }
]

enter image description here

I was expecting:

enter image description here

$\endgroup$
  • $\begingroup$ 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. $\endgroup$ – Michael E2 Nov 7 '14 at 3:09
  • 1
    $\begingroup$ 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}] $\endgroup$ – Simon Woods Nov 7 '14 at 11:26
  • $\begingroup$ @SimonWoods Looks like you nailed it. Would you be so kind as to submit that example to support for me? $\endgroup$ – Mr.Wizard Nov 8 '14 at 15:22
  • 1
    $\begingroup$ Bug report now sent $\endgroup$ – Simon Woods Nov 11 '14 at 11:18
  • $\begingroup$ The bug is still there in 10.0.2. $\endgroup$ – Sjoerd C. de Vries Dec 11 '14 at 19:44
13
$\begingroup$

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}}]

enter image description here

$\endgroup$
  • $\begingroup$ 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. $\endgroup$ – Mr.Wizard Nov 6 '14 at 11:48
  • 1
    $\begingroup$ @Mr.Wizard Unfortunately, I don't know. Obviously, it is a bug in filling (choice of points for polygons is corrupted). $\endgroup$ – ybeltukov Nov 6 '14 at 21:48
6
$\begingroup$

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}}]

Mathematica graphics

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}}]

Mathematica graphics

$\endgroup$
  • 1
    $\begingroup$ Unfortunately neither form shown works in v10. The first looks like i.stack.imgur.com/i93iP.png while the second does not show the brown filling. Bug, I guess. :-/ $\endgroup$ – Mr.Wizard Nov 6 '14 at 3:04
  • 2
    $\begingroup$ @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 :) $\endgroup$ – Dr. belisarius Nov 6 '14 at 3:23
4
$\begingroup$

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}}]

plot

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}}]

plot

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}}]

plot

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}}]

plot

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.