Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

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

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

enter image description here

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

share|improve this question
I didn't expect to see a bounty on this. Thank you, Szabolcs! – Mr.Wizard Jul 21 '15 at 19:01
up vote 14 down vote accepted

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

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

enter image description here

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

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

  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.

share|improve this answer
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] – Bob Hanlon 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. – Mr.Wizard 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. – Bob Hanlon 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. – Alexey Popkov Jul 31 '14 at 18:53
not duplicate but related:… – Mike Honeychurch Jul 31 '14 at 22:54

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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