7
$\begingroup$

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

produces this: enter image description here

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

enter image description here

$\endgroup$
6
  • $\begingroup$ Please do not add the bugs tag until your observations have been confirmed by other users. $\endgroup$ Oct 16, 2015 at 19:22
  • $\begingroup$ OK, got it. Sorry about that. $\endgroup$ Oct 16, 2015 at 19:23
  • 1
    $\begingroup$ This may be relevant: 30145 $\endgroup$
    – N.J.Evans
    Oct 16, 2015 at 19:27
  • 1
    $\begingroup$ In your second case you have reversed the ordering of the lines (introducing the known sorting issue ) $\endgroup$
    – george2079
    Oct 16, 2015 at 21:18
  • 1
    $\begingroup$ The first case is not ordering related. Here is another example Table[ ListLinePlot[ {{{0, 0}, {1, 1}}, {{.2, 0}, {.8, y}, {1, .5}}}, Filling -> {2 -> {{1}, {Green, Red}}}], {y, {.9, 1.1}}] $\endgroup$
    – george2079
    Oct 16, 2015 at 21:41

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.