# How do I combine a function representing an x value with a function representing a y value?

I have two functions, one that generates my x values and one that generates my y values, and I want to merge the data to get a single line plot. This is easily done in excel, but I can't figure out how to do it in mathematica. I did it in excel and it should look like this:. I have written a code that looks like this, where my x and y values are functions of theta

x = 1/72 Cos[θ] (2 + 2 Cos[θ] + 27 Sin[θ])

y = 1/72 Sin[θ] (2 + 2 Cos[θ] + 27 Sin[θ])


I'm pretty sure my issue is just not knowing which plotting function to use, but I could be wrong.

You need to use ParametricPlot:

ParametricPlot[{
1/72 Cos[\[Theta]] (2 + 2 Cos[\[Theta]] + 27 Sin[\[Theta]]),
1/72 Sin[\[Theta]] (2 + 2 Cos[\[Theta]] + 27 Sin[\[Theta]])},
{\[Theta], 0, Pi}]


• u da man, vickto k – orphanpunter69 Apr 6 at 17:00
Clear["Global*"]


ParametricPlotas pointed out by Victor K is the most straightforward approach. You could also Solve for y as a function of x.

sol[x_] = y /. Solve[{
x == 1/72 Cos[θ] (2 + 2 Cos[θ] + 27 Sin[θ]),
y == 1/72 Sin[θ] (2 + 2 Cos[θ] + 27 Sin[θ])},
y, {θ}, Reals];


There are four branches to the solution

Length@sol[x]

(* 4 *)

Plot[Evaluate@sol[x], {x, -0.25, 0.25},
PlotRange -> {{-0.25, 0.25}, {-0.02, 0.42}},
MaxRecursion -> 10,
AspectRatio -> 4/5,
PlotLegends -> Automatic]


The corresponding ParametricPlot(the range of θ is extended to 2 Pi) is

ParametricPlot[{
1/72 Cos[θ] (2 + 2 Cos[θ] + 27 Sin[θ]),
1/72 Sin[θ] (2 + 2 Cos[θ] + 27 Sin[θ])},
{θ, 0, 2 Pi},
PlotRange -> {{-0.25, 0.25}, {-0.02, 0.42}}]
`