# Filling dependence on order of points in ListPlot

ListPlot[{{{1, 0}, {0, 0.5}}, {{1, 1}, {0, 1}}}, Filling -> {1 -> {2}},
FillingStyle -> LightGray, Joined -> True, Frame -> True]


Results in no filling, whereas...

ListPlot[{{{0, 0}, {1, 0.5}}, {{0, 1}, {1, 1}}}, Filling -> {1 -> {2}},
FillingStyle -> LightGray, Joined -> True, Frame -> True]


gives the expected fill.

Why does the order matter or more literally is this expected behavior and if so why?

-

Sort the data

ListPlot[Sort /@
{{{1, 0}, {0, 0.5}}, {{1, 1}, {0, 1}}},
Filling -> {1 -> {2}},
FillingStyle -> LightGray,
Joined -> True,
Frame -> True]


-
That certainly works but don't you think its a bit odd it doesn't work without the Sort? – Ymareth Aug 27 '14 at 15:12
Sort is required because Mma does not know whether you intend the data to be ordered. For example, How would the following be filled? ListPlot[{{{1, 0}, {0, 0.5}, {.5, .75}}, {{1, 1}, {2, .25}, {0, 1}}}, Joined -> True, Frame -> True] – Bob Hanlon Aug 27 '14 at 15:28
I agree your example is ambiguous but mine is not, interpolation between their points in x is not multivalued and the space between the lines is well defined. – Ymareth Aug 27 '14 at 15:50
Presumably the only prior analysis done is to check whether the data is ordered. Your data isn't. OrderedQ /@ {{{1, 0}, {0, 0.5}}, {{1, 1}, {0, 1}}} gives {False, False}. – Bob Hanlon Aug 27 '14 at 16:05
Fair point. I guess I'm assuming that internally some kind of interpolation function is being built and the intersection of support for both objects is constructed. My assumption is most likely wrong because of the counter-cases, like yours, where its not obvious what to do. I'll accept your answer. – Ymareth Aug 27 '14 at 16:38