Message Boards Message Boards

0
|
2552 Views
|
2 Replies
|
2 Total Likes
View groups...
Share
Share this post:

Table of ParametricPlots with differente colors

Posted 9 years ago

Dear Community,

I created a table of several ParametricPlots, such as:

Table[ParametricPlot[{j Sin[u], j Sin[2 u]}, {u, 0, 2 Pi}, PlotRange -> All, AspectRatio -> 1], {j, 0.1, 101, 10}]

and I want that each parametric plot has a different color for each iteration.

Can you please tell me how can I do it?

I have tried ColorFunction -> Function[{j}, Hue[j]] with no success

Many thanks in advance, Sofia

POSTED BY: Sofia Figueiredo
2 Replies

Take a look at the output of Hue in your Table:

Table[Hue[j], {j, 0.1, 101, 10}]

Hue needs a value between 0 and 1. It doesn't know what to do with values outside that range. So let's divide j by 101 so that the values go from 0 to 1. This makes a rainbow

Table[Hue[j/101], {j, 0.1, 101, 10}]

Try using PlotStyle -> Hue[j/101]:

Table[ParametricPlot[{j Sin[u], j Sin[2 u]}, {u, 0, 2 Pi}, 
  PlotStyle -> Hue[j/101], PlotRange -> All, AspectRatio -> 1], {j, 
  0.1, 101, 10}]

ColorFunction can also be used but is more complicated. It controls the color based on the "x, y" values of the plot.

POSTED BY: Sean Clarke

Thanks! :)

POSTED BY: Sofia Figueiredo
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract