I am trying to fill in the area between curves in a parametric plot. I have:

ffA[x_, n_] := MathieuCharacteristicA[n, x]; 
ffB[x_, n_] := MathieuCharacteristicB[n, x];

MathieuPlot =ParametricPlot[{{ffA[x, 1], x}, {ffB[x, 1], x}, {ffA[x, 2], x}, 
{ffB[x, 2], x}, {ffA[x, 3], x}, {ffB[x, 3], x}, {ffA[x, 4], x}, {ffB[x, 4], x}}, 
{x, 0, 10}, AspectRatio -> 1, PlotRange -> {{0, 20}, All}, 
PlotStyle -> Black, Ticks -> None]

enter image description here

I saw the solutions to these questions: 1, 2,3. However, Filling only works for Plot, and solutions 1/2 don't fill in the area between the curves. According to this question, I can shade the area between curves with:

coords = Cases[Normal[MathieuPlot], {dir___, Line[x_]} :> x, Infinity];
Graphics[{{{{{Red, Thick, Line@#, Blue, Line@#2, LightBlue, 
        Polygon[Join[#, Reverse@#2]]} & @@ 
      coords}, {Red, Thick, Line@#3, Blue, Line@#4, LightBlue, 
       Polygon[Join[#3, Reverse@#4]]} & @@ 
     coords}, {Red, Thick, Line@#5, Blue, Line@#6, LightBlue, 
      Polygon[Join[#5, Reverse@#6]]} & @@ 
    coords}, {Red, Thick, Line@#7, Blue, Line@#8, LightBlue, 
     Polygon[Join[#7, Reverse@#8]]} & @@ coords}, 
 AspectRatio -> 1/GoldenRatio, Ticks -> {True, {2, 4, 6, 8, 10}}, 
 Frame -> True]

enter image description here

However, I'm not sure how to only plot the curves to the right of zero. I suspect that it has something to do with how coords is defined, but I am not sure how to modify it. I am also unsure how to make the plots touch the horizontal and vertical axes, similar to the top picture.


1 Answer 1


Update: You can use a single ParametricPlot with the options MeshFunctions and Mesh to get the same result:

ParametricPlot[Evaluate[{ffA[x, #] v + (1 - v) ffB[x, #], x} & /@ Range[4]], 
 {x, -10, 10}, {v, 0, 1}, 
 PlotRange -> All, 
 PlotRangePadding -> None, 
 BoundaryStyle -> None, 
 Frame -> False, 
 Ticks -> False, 
 MeshFunctions -> {#4 &}, 
 Mesh -> {{0, 1}}, 
 MeshStyle -> Opacity[1, Black], 
 AspectRatio -> 1]

enter image description here

Original answer:

You can use a two-parameter ParametricPlot and combine the output with your MathieuPlot using Show:

 ParametricPlot[Evaluate[{ffA[x, #] v + (1 - v) ffB[x, #], x} & /@ Range[4]],
   {x, 0, 10}, {v, 0, 1}, BoundaryStyle -> None]]

enter image description here

Use PlotRange -> All and PlotRangePadding -> None in the first plot and {x, -10, 10} in both plots to get

enter image description here

  • $\begingroup$ This is exactly what I was wondering! Thanks! Do you know if there is a way for the vertical axis to end at the same height as the plot? $\endgroup$
    – user85503
    Dec 25, 2019 at 0:09
  • 1
    $\begingroup$ @user85503, try PlotRangePadding->None (in Show or in ParametricPlot that generates MathieuPlot.) $\endgroup$
    – kglr
    Dec 25, 2019 at 0:17

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.