10
$\begingroup$

My code is

ListLinePlot[{
    {{0, 185}, {-10, 187}, {-20, 186}, {-30, 158}, {-40, 159}, {-60, 116}}, 
    {{0, 155}, {-10, 132}, {-20, 165}, {-30, 112}, {-40, 85}, {-60, 95}}}, 
  Filling -> {1 -> {2}}]

Why doesn't Filling work on my plot?

$\endgroup$
1
  • 1
    $\begingroup$ Perhaps it's just a sanity check. ListLinePlot[Transpose@{{3, 4, 6, 5, 7, 8}, {2, 2, 1, 1, 2, 2}}, PlotRange -> {0, 3}, Filling -> Axis] $\endgroup$ Aug 9, 2013 at 12:14

1 Answer 1

11
$\begingroup$

Actually, this is more a long comment than a full answer. It seems to me that it is struggling with the fact that you (1.) supply x-coordinate in (2.) decreasing/"unsorted" order. Sorting it fixes it, try:

ListLinePlot[{
    Sort@{{0, 185}, {-10, 187}, {-20, 186}, {-30, 158}, {-40, 159}, {-60, 116}}, 
    Sort@{{0, 155}, {-10, 132}, {-20, 165}, {-30, 112}, {-40, 85}, {-60, 95}}}, 
    Filling -> {1 -> {2}}]

Alternatively, in your case (of strictly decreasing x-coords), you could use Reverse.

For the "Why?", I do not know, maybe somebody else can help? (I cannot see a word on that in ListLinePlot documentation, in particular in the possible issues section)

$\endgroup$
3
  • $\begingroup$ I note that you specify the Filling option differently than the OP. Any reason for that? $\endgroup$ Aug 9, 2013 at 12:35
  • $\begingroup$ Good eyes! I was playing around a bit with other things and trying out stuff, forgot to change back. {1->{2}} and {2->{1}} shouldn't change a thing. Thanks for pointing that out! $\endgroup$ Aug 9, 2013 at 12:40
  • 6
    $\begingroup$ See "Unordered data may display in unexpected ways" $\endgroup$
    – Michael E2
    Aug 9, 2013 at 17:42

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.