0
$\begingroup$

I want to create a ParametricPlot with multiple Piecewise functions in it. I have tried the following code but it doesn't work

ParametricPlot[Piecewise[{{Cos[x] + x/2, 1 > x > 16}, {Sin[x], 16 > x > 20}}], {x, 0, 21}, Axes -> True]

Basically I want my graph to show a loop but only for a certain interval, as shown in this image:

loop

I used the following command for it:

ParametricPlot[{Cos[x] + x/2, Sin[x]}, {x, 1, 16}]
$\endgroup$
  • $\begingroup$ Welcome to Mathematica.SE! I hope you will become a regular contributor. To get started, 1) take the introductory Tour now, 2) 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, 3) remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign, and 4) give help too, by answering questions in your areas of expertise. $\endgroup$ – bbgodfrey Sep 1 '15 at 2:45
  • $\begingroup$ I'm still confused. It seems like you managed to plot what you wanted. Do you mean you want this same plot, just with PlotRange -> {{1, 20}, All}? Or do you want some other function plotted for 16 < x < 20 (because that is not at all clear from your initial attempt)? If so, please provide this other function. $\endgroup$ – march Sep 1 '15 at 3:31
  • $\begingroup$ Let me get this straight: you are plotting a trochoid, and you only want a few pieces of it, yes? Then you don't need the complication of Piecewise[]. $\endgroup$ – J. M. is away Sep 1 '15 at 4:17
2
$\begingroup$

For example:

ParametricPlot[{Cos[x] + x/2, Sin[x]}, {x, 0, 21}, Axes -> True, 
               RegionFunction -> (0 < #1 < 4 || 6 < #1 < 8 &)]

Mathematica graphics

$\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.