The top one is fine, but if I change Red into dashed version, it behaves erratically.
Asked
Active
Viewed 621 times
1 Answers
6
I think the behavior of LineLegend exhibited in the question, if not a bug, is within an epsilon of a bug. Consider that the following all succeed ...
LineLegend[{{Red, Dashed}, Green, Blue}, {"r", "g", "b"}]
LineLegend[{{Red, Dashed}, {Green, Dashed}, Blue}, {"r", "g", "b"}]
LineLegend[{Directive[Red, Dashed], {Green, Dashed}, {Blue, Dashed}}, {"r", "g", "b"}]
LineLegend[{{Red, Dashed}, Directive[Green, Dashed], {Blue, Dashed}}, {"r", "g", "b"}]
LineLegend[{{Red, Dashed}, {Green, Dashed}, Directive[Blue, Dashed]}, {"r", "g", "b"}]
... and that this is the only failure case.
LineLegend[{{Red, Dashed}, {Green, Dashed}, {Blue, Dashed}}, {"r", "g", "b"}]
The singleton nature of the failure strikes me as indicating there is some edge case that has been missed in the Mathematica code underlying the evaluation or internal use of the 1st argument of LineLegend.
m_goldberg
- 107,779
- 16
- 103
- 257
-
1It's an "internal" use to make it compatible with
ChartLegends, see the output ofBarChartwith multiple data sets. – rcollyer Aug 09 '16 at 13:03 -

Directive[Blue,Dashed]instead of{Blue, Dashed}. – Szabolcs Feb 20 '16 at 00:36Directiveshould always be used instead of{...}when specifying a list of styles... (like in legends, PlotStyle, etc.) Lists are ambiguous and cause problems. – Szabolcs Feb 20 '16 at 00:43