4
$\begingroup$

There are some similar questions: (1) (2) have been ask, but I think this is a different one.

If we have a ParametricPlot and a Plot, how to Filling between them. For example, the ParametricPlot is $(\cos^2(x)+x, x-\sin(x))$, the Plot is $y=x$, and the plot range is $(0,1)$.

$\endgroup$
  • 3
    $\begingroup$ Please try to write down the code for the parametric plot and the plot. Thanks. $\endgroup$ – Dr. belisarius Oct 26 '14 at 16:10
7
$\begingroup$
p1[x_] := {Cos@x^2 + x, x - Sin@x}; 

Plot[{x, p1[t][[2]] /. FindRoot[p1[t][[1]] == x, {t, 1}]}, {x, 0, 5}, 
     Filling -> {1 -> {2}}]

Mathematica graphics

Or perhaps better:

p = {Cos@#^2 + # &, # - Sin@# &};
Plot[{x, p[[2]]@InverseFunction[p[[1]]]@x}, {x, 0, 5}, Filling -> {1 -> {2}}]

Mathematica graphics

$\endgroup$
0
$\begingroup$

You can post-process the output of ParametricPlot to change lines into a polygon:

pplt = ParametricPlot[{{x , x}, {Cos[x]^2 + x, x - Sin@x}}, {x, 0, 5}];

coords = Cases[Normal[pplt], {dir___, Line[x_]} :> x, Infinity];
Graphics[{{Red, Thick, Line @ #, Blue, Line @ #2, LightBlue,
  Polygon[Join[#, Reverse @ #2]]} & @@ coords}, 
 Frame -> True, AspectRatio -> 1 / GoldenRatio]

enter image description here

$\endgroup$

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.