9
$\begingroup$

The code below gives color-varying points with explicit Style wrappers:

ListPlot[Table[Style[{Cos[t], Sin[2 t]}, Hue[t/(2 Pi)]], {t, 0, 2 Pi,Pi/20}],PlotStyle -> PointSize[Medium]]

enter image description here

However, when I want to change the marker shape with PlotMarkers, the color settings are shadowed with default color:

ListPlot[Table[  Style[{Cos[t], Sin[2 t]}, Hue[t/(2 Pi)]], {t, 0, 2 Pi, Pi/20}], PlotStyle -> PointSize[Medium], PlotMarkers -> Automatic]

enter image description here

My questions are:

  1. Can such behavior be considered as a bug?

  2. What is the workaround for changing to another marker?

$\endgroup$
2
  • 1
    $\begingroup$ related Q/A $\endgroup$
    – kglr
    Commented Feb 3, 2016 at 15:51
  • 3
    $\begingroup$ On a scale of 0 (feature) to 10 (bug), this is probably an 8. (It's not what I'd expect, but there may be some good reason for it, and it doesn't entirely surprise me.) $\endgroup$ Commented Feb 3, 2016 at 22:18

1 Answer 1

9
$\begingroup$

Edit My previous answer was just a workaround, and it involved putting the color as a graphics directive for the individual plotmarkers.

My thanks to @rcollyer for bringing an undocumented option to my attention which is the true solution to this problem. You just need to set Method -> {"OptimizePlotMarkers" -> False}

ListPlot[Table[
  Style[{Cos[t], Sin[2 t]}, Hue[t/(2 Pi)]], {t, 0, 2 Pi, Pi/20}], 
 PlotStyle -> PointSize[Medium], PlotMarkers -> Automatic, 
 Method -> {"OptimizePlotMarkers" -> False}]

enter image description here

$\endgroup$
2
  • $\begingroup$ Thanks for the workaround. I might wait for one day to see if more opinions can appear. $\endgroup$
    – sunt05
    Commented Feb 3, 2016 at 19:54
  • $\begingroup$ The edit is great! It also reminds me that how many undocumented features are there to explore! $\endgroup$
    – sunt05
    Commented Feb 18, 2016 at 7:58

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.