Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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
]

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

1 Answer 1

up vote 6 down vote accepted

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

ListLinePlot[data,
  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.:

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 appends the style information to the front of it.

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 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 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 at 18:23
1  
@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 at 18:53
1  
not duplicate but related: mathematica.stackexchange.com/questions/5400/… –  Mike Honeychurch Jul 31 at 22:54

Your Answer

 
discard

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.