Changing Plot Color in Mathematica

Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
1 reply · 21K views
roam
Messages
1,265
Reaction score
12
I want to generate the following plot in Mathematica in red color:

Code:
x[t_] := 31 Cos[t] - 7 Cos[31 t/7];
y[t_] := 31 Sin[t] - 7 Sin[31 t/7];
ParametricPlot[{x[t], y[t]}, {t, 0, 19 \[Pi]}]

The above code creates the plot in default black color. So, I tried using this code to make it red:

Code:
x[t_] := 31 Cos[t] - 7 Cos[31 t/7];
y[t_] := 31 Sin[t] - 7 Sin[31 t/7];
ParametricPlot[[{x[t], y[t]}, {t, 0, 19 \[Pi]}],
PlotStyle -> {{RGBColor[1,0,0]}}]

Unfortunently it doesn't work and I get errors. Can anybody help with this?
 
Physics news on Phys.org
You've got too many braces! Here's the working code:

Code:
x[t_] := 31 Cos[t] - 7 Cos[31 t/7];
y[t_] := 31 Sin[t] - 7 Sin[31 t/7];
ParametricPlot[{x[t], y[t]}, {t, 0, 19 \[Pi]}, 
 PlotStyle -> {RGBColor[1, 0, 0]}]

Alternatively, you can just pass the name of the color directly to PlotStyle:

Code:
x[t_] := 31 Cos[t] - 7 Cos[31 t/7];
y[t_] := 31 Sin[t] - 7 Sin[31 t/7];
ParametricPlot[{x[t], y[t]}, {t, 0, 19 \[Pi]}, 
 PlotStyle -> {Red}]

http://img39.imageshack.us/img39/7893/64328066.jpg
 
Last edited by a moderator: