Changing Plot Color in Mathematica

Click For Summary
SUMMARY

The discussion focuses on changing the plot color in Mathematica using the ParametricPlot function. The user initially attempts to set the plot color to red using incorrect syntax, resulting in errors. The correct implementation involves using either RGBColor or directly specifying the color name 'Red' within the PlotStyle option. The final working code successfully generates the desired red plot without errors.

PREREQUISITES
  • Familiarity with Mathematica syntax
  • Understanding of the ParametricPlot function
  • Knowledge of color specifications in Mathematica
  • Basic experience with defining functions in Mathematica
NEXT STEPS
  • Explore advanced color options in Mathematica, such as ColorData
  • Learn about customizing plot styles in Mathematica
  • Investigate the use of RGBColor for creating custom colors
  • Study the implications of different plotting functions in Mathematica
USEFUL FOR

Mathematica users, data visualizers, and anyone interested in enhancing their graphical outputs in Mathematica.

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 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 4 ·
Replies
4
Views
4K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K