Message Boards Message Boards

GROUPS:

Use ColorData on a list to get a list of colors covering all SiennaTones?

Posted 20 days ago
134 Views
|
1 Reply
|
0 Total Likes
|

Hi there, want to plot some rays with "warm" colors, so I started with a radial ray with a few points.

ray = Flatten[ Table[{r Cos[Theta], r Sin[Theta]}, {r, 0, 1, 0.1}, {Theta, 0.7, 0.7}], 1];

After reading mathematica help I believe the result of this command

ColorData[{"SiennaTones", "Reverse"}][#/(Max[ray[[All, 2]]])] & /@ 
 ray[[All, 2]]

is going to inform me of the colors that the 11 points in the initial list will have when using that command as an option to ListPlot. That command produces an array of colors covering the whole range of SiennaTones, which range from whiteish to brown. So I do it like this:

ListPlot[ray, 
 PlotStyle -> ({PointSize[0.01], 
      ColorData[{"SiennaTones", "Reverse"}][#]} & /@ ray[[All, 2]])]

And all I get are whiteish points. Can anybody kindly help me?

Thanks,

Ruth

Attachments:
Posted 20 days ago

When you give PlotStyle a list, it wants to look at the first argument and find a list of the same length. But in this case, since you are calling ListPlot - you need the first argument to be a list of lists with the same length as the list of styles. So you could do this:

ListPlot[Thread[{ray}], 
 PlotStyle -> ({PointSize[0.01], 
      ColorData[{"SiennaTones", "Reverse"}][#]} & /@ ray[[All, 2]])]

But if you look at the doc page for ListPlot, there is a documented way to color each point individually using Style. So this also works:

ListPlot[Style[#, ColorData[{"SiennaTones", "Reverse"}][#[[2]]]] & /@ 
  ray, PlotStyle -> PointSize[0.01]]
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