1
$\begingroup$

I would like to create a LineLegend that incorporates both coloured and dashed lines. I expected this to be simple, but I'm missing something.

The below will give the LineLegend with either linestyle defined, or the colour defined - how do I do both?

LineLegend[{Line, Dashed, Dotted}, {"red line", "green dashed", 
  "blue dotted"}]
LineLegend[{Red, Green, Blue}, {"red line", "green dashed", 
  "blue dotted"}]

I tried

LineLegend[{{Dashed, Red}, {Line, Blue}, {Green, Dotted}}, {"red", 
  "green", "blue"}]

but got no output

$\endgroup$
0
$\begingroup$

Line is not a directive. You can remove it.

LineLegend[{Red, {Dashed, Green}, {Dotted, Blue}}, 
  {"red line", "green dashed", "blue dotted"}]

enter image description here

Alternatively, you can use Dashing[{}] to get a solid line:

LineLegend[Thread[Directive[{Red, Green, Blue}, {Dashing[{}], Dashed, Dotted}]],
  {"red line", "green dashed", "blue dotted"}]

enter image description here

| improve this answer | |
$\endgroup$
0
$\begingroup$

I would like to create a LineLegend that incorporates both coloured and dashed lines.

LineLegend[{Directive[{Dashed, Red}], {Line, Blue}, {Green, 
   Dotted}}, {"red", "green", "blue"}]

enter image description here

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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