3
$\begingroup$

Simple Question from a Stumped Rookie:

Using ListPlot, I can't get PlotStyle to look below the first level of a nested list to assign individual saturation values for each point; it assigns the first three saturation values to the first three groups of points.

pts = {{{0.10, 485}, {0.22, 495}, {0.35, 500}},
       {{0.94, 739}, {2.95,814}}, {{3.47, 802}}};
saturationList = {1, .5, .2, .5, .3, .7};
colors[sat_] := Hue[1, sat];
myPlotStyle = Map[colors, saturationList];
ListPlot[pts, PlotStyle -> myPlotStyle]

I ultimately want to assign different colors to each group while assigning unique saturation values to each point.

$\endgroup$

2 Answers 2

1
$\begingroup$

I think it will be better to use Graphics

pts = {{{0.10, 485}, {0.22, 495}, {0.35, 500}},
       {{0.94, 739}, {2.95, 814}}, {{3.47, 802}}};
saturationList = {.5, .2, .5, .3, .7};
col = {Red, Blue, Green, Brown};
Graphics[Table[{PointSize[Large], 
 Lighter[col[[i]], saturationList[[#]]], Point[pts[[i]][[#]]]} & /@
 Range[Length[pts[[i]]]], {i, Length[pts]}], AspectRatio -> 1, Frame -> True]    

enter image description here

Or you can use Hue as

Graphics[Table[{PointSize[Large], Hue[i, saturationList[[#]]], 
 Point[pts[[i]][[#]]]} & /@ Range[Length[pts[[i]]]], {i, 
 Length[pts]}], AspectRatio -> 1, Frame -> True]
$\endgroup$
1
$\begingroup$

Use Hue[h,s] to distinguish between groups via h and within groups via s:

pts = {{{0.10, 485}, {0.22, 495}, {0.35, 500}},
       {{0.94, 739}, {2.95,814}}, {{3.47, 802}}};
saturationList = {1, .5, .2, .5, .3, .7};

sl = MapIndexed[Thread[{#2[[1]], #}]&, Internal`PartitionRagged[saturationList,
               Length /@ pts], {1}];

newpts = Style[{#, #2}, Hue[#3/ Length[pts], #4]] & @@@ (Join @@ (Join @@@ # & /@ 
      Transpose /@ Transpose[{pts, sl}]));

ListPlot[newpts, BaseStyle -> PointSize[.025]]

Mathematica graphics

$\endgroup$
1
  • $\begingroup$ Very Helpful! Thank you! $\endgroup$ Commented May 31, 2016 at 8:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.