0
$\begingroup$

The data at the bottom generates the ListLinePlot also shown below. Now I would like to Fill under the line, but only in the regions where the line is less than or equal to 0.5 (there may be multiple, separated regions in general).

@void life provided a solution without the restriction in comment here, which I state below too. I have been unable to work out how to introduce the restriction in void life's code:

Void Life's partial solution:

ListLinePlot[{data, Min[1/2, #] & /@ data}, PlotStyle -> {Automatic, None}, Filling -> {1 -> 0, 2 -> {{1}, White}}]

Data:

{0.744318, 0.60038, 0.539471, 0.5542, 0.592916, 0.613237, 0.673014,0.687572,0.658548, 0.69416, 0.65248, 0.653574, 0.596889, 0.577856, 0.592349, 0.505633, 0.51403, 0.520655, 0.492696, 0.459513, 0.463524, 0.463181, 0.415386, 0.422303, 0.422072, 0.406222, 0.40379, 0.389445, 0.375038, 0.349756, 0.332508, 0.323173, 0.308245, 0.290745, 0.285053, 0.275322, 0.268835, 0.25514, 0.25281, 0.254935, 0.250978, 0.251613, 0.25431, 0.251915, 0.252345, 0.253374, 0.253928, 0.248666, 0.25169, 0.253212, 0.257687, 0.257374, 0.256379, 0.262966, 0.263945, 0.268633, 0.270197, 0.273909, 0.274298, 0.275465, 0.274321, 0.273316}

enter image description here

$\endgroup$
0
$\begingroup$

If I understand correctly you just want to fill the region of the curve that is less than 0.5?

data = (* your list *)
data = Transpose@{Range[Length[data]],data}

ListLinePlot[{data, Select[data, LessThan[0.5]@*Last]}, 
             PlotStyle -> {Automatic, None}, Filling -> {2 -> {0, LightBlue}}]

enter image description here

Ps. You should perhaps ask your 'real' question immediately instead of incrementally changing the question through edits when someone provides an answer.

$\endgroup$
  • $\begingroup$ I agree, and I do apologize. The reason I tried it the way I did was that I also received advice from Michael E2 that I should do the opposite! That is, to keep things simple. But the risk is as we have seen. $\endgroup$ – user120911 Jan 14 at 12:17
  • $\begingroup$ Further on this, perhaps a good strategy is to provide the real problem, and what one thinks is the boiled-down version - then somebody with greater knowledge can catch the mistake in that belief, if there is one. $\endgroup$ – user120911 Jan 14 at 12:19
  • $\begingroup$ No worries. I agree that should keep things simple. Eg. Don't just dump your whole notebook worth of code when your problem is just in one tiny section. But do try to describe your real problem with a minimal example instead of a describing a toy problem. $\endgroup$ – void life Jan 14 at 12:33

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.