Bug introduced in 9.0 or earlier and persisting through 13.2.0 or later
I'm trying to understand this apparently incorrect Filling
behavior in ListLinePlot[]
. Evaluating this
Table[ListLinePlot[
{{{-6.62, -25.469}, {-6.59, y}},{{-6.62, -25.55}, {-6.57, -25.7}}},
PlotStyle -> Thickness[0.01], PlotRange -> {{-6.63, -6.52}, {-25.8, -25.4}},
ImageSize -> 500, Filling -> {2 -> {{1}, {Green, Red}}}
], {y, {-25.68, -25.72}}]
The Filling
option is supposed to be filling green above the orange line and red below it, but this breaks when one slightly adjusts the y-value of the endpoint of the blue line so that it is above the endpoint of the orange line.
This issue also exists in ListPlot[]
using the Joined->True
option. I'm using Mathematica 10.3.0.0.
I suspect this is related to the problem with needing to sort the data points for Filling
to work. (Otherwise, it fails silently, which is horrendously confusing for beginners.) However, in this case, there are only two points for each line, and they are sorted. I haven't been able to figure out exactly what's going on, and what to do to avoid it. It may also be related to this apparent bug, but there don't seem to be any new points created.
EDIT: Here is a slightly more minimal example, thanks to george2079, confirming that this is not just another example of the ordering problem.
Table[ ListLinePlot[
{{{0, 0}, {1, 1}}, {{.2, 0}, {.8, y}, {1, .5}}},
Filling -> {2 -> {{1}, {Green, Red}}}
], {y, {.9, 1.1}}]
Table[ ListLinePlot[ {{{0, 0}, {1, 1}}, {{.2, 0}, {.8, y}, {1, .5}}}, Filling -> {2 -> {{1}, {Green, Red}}}], {y, {.9, 1.1}}]
$\endgroup$