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.

I am using Mathematica 9. The problem I have is with plotlengends, in particular,

g2 = ListPlot[{{2, 1}, {3, 4}, {3.5, 4.2}, {4, 6}}, 
  PlotStyle -> {Dashing[Large]}, PlotLegends -> {"Dashed"}, 
  Joined -> True];
g1 = ListPlot[{{2, 1}, {3, 4}, {3.5, 4.2}, {4, 6}, {4.5, 6.6}, {5, 
    7}, {6, 9}, {8, 11}}, Joined -> True, PlotStyle -> {Dotted}, 
  PlotLegends -> {"Dot"}];
Show[g1, g2]

enter image description here

As you can see, the problem is that looking at this lengends, there is no way you can tell which curve coresponds to which one in the legends (for instance, is the dash curve coresponds to the top legend or the bottom legend?). Changing the color will not work because this plot has to be in black and white only. Please help.

share|improve this question
    
Works perfectly with me: "10.0 for Microsoft Windows (64-bit) (June 29, 2014)" –  eldo Aug 31 at 17:15
    
Sorry, it is matehamtica 9 –  kuku Aug 31 at 17:15

2 Answers 2

up vote 9 down vote accepted

As noted by Eldo, this works out of the box on Mathematica 10. On Mathematica 9 LineLegend does the trick:

data2 = {{2, 1}, {3, 4}, {3.5, 4.2}, {4, 6}};
data1 = {{2, 1}, {3, 4}, {3.5, 4.2}, {4, 6}, {4.5, 6.6}, {5, 7}, {6, 9}, {8, 11}};

ListPlot[
 {data1, data2}, 
 Joined -> True, 
 PlotStyle -> {Dotted, Dashing[Large]}, 
 PlotLegends -> LineLegend[{Dotted, Dashing[Large]}, {"Dot", "Dashed"}]
]

Mathematica graphics

share|improve this answer

This works with both versions:

g2 = ListPlot[{{2, 1}, {3, 4}, {3.5, 4.2}, {4, 6}}, 
   PlotStyle -> {Dashing[Large]}, Joined -> True];

g1 = ListPlot[{{2, 1}, {3, 4}, {3.5, 4.2}, {4, 6}, {4.5, 6.6}, {5, 
     7}, {6, 9}, {8, 11}}, Joined -> True, PlotStyle -> {Dotted}];

Legended[Show[g1, g2], 
 LineLegend[{Dashed, Dotted}, {"Dashed", "Dot"}]]

enter image description here

share|improve this answer

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.