# How to make PlotMarkers constructed from Graphics track plot style?

In this plot the Disk[] markers are not colored according to the style of the line to which they belong:

SeedRandom[12]
data = Accumulate /@ RandomReal[3, {4, 10}] {1, 2, 3, 4};

ListLinePlot[data,
PlotMarkers -> Graphics[Disk[], ImageSize -> 13],
PlotLegends -> Automatic
]


Curiously, note that they are colored in the legend. How can I make the lines match the legend?

• I didn't expect to see a bounty on this. Thank you, Szabolcs! Jul 21 '15 at 19:01

Though I was expecting to need something fancy I stumbled upon a simple solution:

ListLinePlot[data,
PlotMarkers -> Graphics[{Disk[]}, ImageSize -> 13],
PlotLegends -> Automatic
]


The only change is enclosing Disk[] in { }.

Looking at the InputForm we see that expressions involving Disk have been changed to e.g.:

Graphics[{
Hue[0.67, 0.6, 0.6], Directive[PointSize[0.019444444444444445],
RGBColor[0.368417, 0.506779, 0.709798], AbsoluteThickness[1.6]],
Disk[{0, 0}]
}, ImageSize -> 13]


Apparently when a List appears as the first argument of Graphics the plot routine prepends the style information.

As far as I know this behavior is undocumented.

• You used a degenerate case (single element, i.e., cycle of one) of the documented: "With PlotMarkers -> {Subscript[g, 1],[Ellipsis],Subscript[g, n]} the Subscript[g, i] are used cyclically for successive dataset lists." (from PlotMarkers documentation) However, using Automatic markers enables distinguishing the different lines even when seen in black and white. ListLinePlot[data, PlotMarkers -> {Automatic, 16}, PlotLegends -> Automatic] Jul 31 '14 at 17:45
• @BobHanlon I don't know if I understand your point but if I do I do not agree with it. I am using the form: "g markers consisting of copies of expression g" There is nothing "degenerate" about it that I can see. Jul 31 '14 at 18:04
• My interpretation is that the list you added inside of the Graphics constitutes the cycle list (length of one) used for the markers. But I could easily be wrong. Jul 31 '14 at 18:23
• @BobHanlon The same behavior is observed in non-degenerated cases (in your sense): ListLinePlot[data,PlotMarkers->{Graphics[Disk[],ImageSize->13],Graphics[Disk[],ImageSize->13]}]. So your interpretation is wrong. Personally I think it is just an ordinary example of gedanken functionality in Mathematica: the developer simply forgot to handle the case when the first argument of Graphics is not wrapped by List. Jul 31 '14 at 18:53
• not duplicate but related: mathematica.stackexchange.com/questions/5400/… Jul 31 '14 at 22:54