Mathematica Changing Plot Color in Mathematica

AI Thread Summary
The discussion focuses on generating a red-colored plot in Mathematica using parametric equations. The initial attempt to set the plot color using incorrect syntax led to errors. The correct approach involves using the `PlotStyle` option properly. The working solution is provided as: 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]}].An alternative method is also suggested, where the color can be directly specified as `Red` in the `PlotStyle`. This ensures the plot is displayed in the desired red color without syntax errors.
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:

Similar threads

Replies
1
Views
2K
Replies
1
Views
2K
Replies
8
Views
2K
Replies
1
Views
2K
Replies
2
Views
1K
Replies
4
Views
3K
Replies
1
Views
2K
Replies
2
Views
2K
Back
Top