This is unrelated to my previous question, but is based on it. The following example works fine:
data1 = {{{1, 2}, Red}, {{2, 3}, Blue}};
ListPlot[
List /@ data1[[;; , 1]],
PlotMarkers ->
Apply[Graphics[{#, Rectangle[]}, ImageSize -> 15] &,
List /@ data1[[;; , 2]], {1}]
]
If we replace it, however, with
ListPlot[
List /@ data1[[;; , 1]],
PlotMarkers -> Graphics[{#, Rectangle[]}, ImageSize -> 15] & /@ data1[[;; , 2]]
]
It doesn't work -- colors are the same. This can be fixed using Evaluate
ListPlot[List /@ data1[[;; , 1]],
PlotMarkers ->
Evaluate@(Graphics[{#, Rectangle[]}, ImageSize -> 15] & /@ data1[[;; , 2]])
]
Now we can suspect that ListPlot has HoldAll
attributes, so we everything that needs to be evaluated (and Map does) will be held. However, unlike Plot, ListPlot doesn't have the HoldAll attribute
Plot // Attributes
ListPlot // Attributes
{HoldAll, Protected, ReadProtected}
{Protected, ReadProtected}
So, what's happening here?
Evaluateoverrides this default precedence? – Stitch Jan 29 '17 at 01:16(after yourEvaluatedoes that. – Felix Jan 29 '17 at 02:22