Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Changing Plot Color in Mathematica

  1. Jan 18, 2010 #1
    I want to generate the following plot in Mathematica in red color:

    Code (Text):
    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 (Text):
    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?
     
  2. jcsd
  3. Jan 18, 2010 #2
    You've got too many braces! Here's the working code:

    Code (Text):

    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 (Text):

    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 [Broken]
     
    Last edited by a moderator: May 4, 2017
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook