2
$\begingroup$

I have the following plot, where {vsoundAll, decAll, pdivAll} are already given in some array and are irrelevant here. I am trying to fill the region between the yellow and red light using the command, Filling -> {2->{3}} but it does not works. What am I missing here? Here is my snippet. Thank you in advance

ListLinePlot[{vsoundAll, decAll, pdivAll}, Frame -> True, 
PlotRange -> {{0.01, 0.4}, {0, 2}}, 
PlotStyle -> {"DarkColor", "Saphire", Red}, 
Filling -> {1 -> Top, 3 -> Top, 2 -> {3}}]

enter image description here

$\endgroup$
4
  • $\begingroup$ Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Take the tour! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! $\endgroup$
    – Michael E2
    Feb 9, 2021 at 21:21
  • $\begingroup$ While {vsoundAll, decAll, pdivAll} are probably irrelevant here, from a problem-solving-strategy point of view, such assumptions are sometimes the reason problems don't get solved. For instance, this works for me: ListLinePlot[Table[Log[x] + k, {k, 3}, {x, 10}], Frame -> True, PlotRange -> {{1, 10}, {0, 6}}, PlotStyle -> {"DarkColor", "Saphire", Red}, Filling -> {1 -> Top, 3 -> Top, 2 -> {3}}] $\endgroup$
    – Michael E2
    Feb 9, 2021 at 21:27
  • $\begingroup$ Well, what I meant was that the data comes from some numerical solutions and it was already organized in tables, so there was no need to show that here. As @kglr showed, the problem is fixed by using Join[decAll, Reverse@pdivAll]. Thanks $\endgroup$
    – CamPos
    Feb 10, 2021 at 16:56
  • 1
    $\begingroup$ He also showed he needed equivalent data to figure it out. Not everyone would go to the trouble of constructing data you could have supplied. $\endgroup$
    – Michael E2
    Feb 10, 2021 at 21:09

2 Answers 2

3
$\begingroup$
compressed = "1:eJzV3VFoVmUYB/\
CzTdtsrVxrLTPZVk5dM5eNESKyCwkRClMvRIYXy1RGmYRGSBci4oWIGIhIF+\
I3diESXoiIFyKyi6joIqK6iIguJKKLiOg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bYla6z1/\
hC7Z0gpZ2Us7QuVs4UNhW4UvQPALi4qTwJWjiybhiJOykxCx/M6OgYvJOCl+\
CBpVed1JW0LmLSq87KXxRHVR63Unhi+r01/97tgpfVOcYaGknhS+\
qgwqVOyl8UR1UqNxJ4YvqHAUt7aTwRXVQWW8nJf+BG9u31We5rTJFxwUVwXZS+\
KI6qAi2kzJNxwUVwXZS+KI6qGS0kxLPE1Q/\
jUpGOyl8UR1UMtpJ4YvqoALLTgpfVAcVWHZS+KI6qByxk8IX1UHliJ0UvqhOS/2/\
Z6vwRXVQ8V4nhS+qg4r3Oil8UR1U6tZJ4YvqoFK3TgpfVAcVhnVS+\
KI6qDCsk8IX1UFlVJ0UvqgOKqPqpPBFdW7/TxS+\
qA4qOuqk8EV1UIlOJ4UvqoNKdDopfFEdVNDSSeGL6qCClk4KX1QHFbR0UviiOqigpZPCF9\
VB5R+dFL6oDir/6KTwRXXibW7FmMRJ4YvqoPKPTsrMHeVvgxXDlA==";

Uncompress to get the three lists:

{vsoundAll, decAll, pdivAll} = Uncompress[compressed];

Replicate the issue:

ListLinePlot[{vsoundAll, decAll, pdivAll}, 
 Frame -> True, Joined -> True,
 PlotRange -> {{0.01, .4}, {0, 2}}, 
 PlotStyle -> {"DarkColor", "Spahire", Red}, 
 Filling -> {1 -> Top, 3 -> Top, 2 -> {3}}]

enter image description here

Several ways to fix:

1. Combine the second and third lists as Join[decAll, Reverse@pdivAll] and use it as the fourth input list and add 4 -> Bottom to the Filling option setting:

ListLinePlot[{vsoundAll, decAll, pdivAll, Join[decAll, Reverse@pdivAll]}, 
 Frame -> True, Joined -> True,
 PlotRange -> {{0.01, .4}, {0, 2}}, 
 PlotStyle -> {"DarkColor", "Spahire", Red, LineOpacity -> 0}, 
 Filling -> {1 -> Top, 3 -> Top, 4 -> {Bottom, LightGreen}}]

enter image description here

2. Construct a FilledCurve or Polygon using decAll and Reverse @ pdivAll:

ListLinePlot[{vsoundAll, decAll, pdivAll}, 
 Frame -> True, Joined -> True,
 PlotRange -> {{0.01, .4}, {0, 2}}, 
 PlotStyle -> {"DarkColor", "Spahire", Red}, 
 Filling -> {1 -> Top, 3 -> Top, 2 -> {3}}, 
 Epilog -> {LightOrange, FilledCurve[Line /@ {decAll, Reverse@pdivAll}]}]

enter image description here

Using

Epilog -> {LightOrange, Polygon[Join[decAll, Reverse@pdivAll]]}

gives the same picture.

3. An alternative approach is to create BSplineFunctions from decAll and pdivAll and plot them using ParametricPlot:

Show[ListLinePlot[{vsoundAll, decAll, pdivAll}, Frame -> True, 
  PlotRange -> {{0.01, .4}, {0, 2}}, 
  PlotStyle -> {"DarkColor", "Spahire", Red}, 
  Filling -> {1 -> Top, 3 -> Top, 3 -> {2}}], 
 ParametricPlot[v BSplineFunction[decAll][t] +
   (1 - v) BSplineFunction[pdivAll][t], 
  {t, 0, 1}, {v, 0, 1}, AspectRatio -> 1/GoldenRatio, 
  PlotStyle -> Green, BoundaryStyle -> None]]

enter image description here

$\endgroup$
1
  • $\begingroup$ Thanks a lot for your response. Number 1 fix worked great ;-). I have to admit that I would not think about Join[decAll, Reverse@pdivAll], did not see any of this in the docs. $\endgroup$
    – CamPos
    Feb 10, 2021 at 16:54
2
$\begingroup$

Is this what you need? I made up some data because you did not specify.

dat1 = Table[{x, 1 - 2 x^2}, {x, 0, 1, .1}];
dat2 = Table[{x, (1 - 10 x^2)}, {x, 0, 1, .1}];
ListLinePlot[{dat1, dat2}, PlotRange -> {0, 1}, 
 Filling -> {2 -> {{1}, Yellow}}]

enter image description here

$\endgroup$
2
  • $\begingroup$ Yes, that's what I'm looking for, but for some reason it is not working for me. The data I have come from some numerical solutions and it's a bit long table, so that's why I did not post it. Thanks ayways $\endgroup$
    – CamPos
    Feb 9, 2021 at 17:24
  • $\begingroup$ You are welcome. You could still thin out your data and post it. $\endgroup$ Feb 9, 2021 at 17:32

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.