PlotLegends in ListPlot does not display different markers

I would like to plot a graph with the legends at its side. However, I have managed to plot the legends, but the markers do not match the one in plot (picture bellow):

My code for that plot is:
ListPlot[{Table[{(n – 1/2)*1/1000, VelocityU[[1, n]]}, {n, 1, NN}],
Table[{(n – 1/2)*1/1000, VelocityU[[SI, n]]}, {n, 1, NN}]},
Joined -> True, Filling -> None, PlotMarkers -> Automatic,
PlotStyle -> {{Blue, Thin}, {Blue, Thin}},
PlotRange -> {{0, (NN)*1/1000}, Automatic}, Frame -> True,
FrameLabel -> {“y [m]”, “U(y) [m/s]”},
GridLines -> {Range[1/1000, 1/100, 0.001], Automatic},
GridLinesStyle -> {{Dashed, Lighter[Gray], Thin}, {Dashed,
Lighter[Gray], Thin}},
FrameTicksStyle -> Directive[FontSize -> 8],
PlotLegends -> {“U(y, i = 1)”, “U(y, i = 400)”}]

I have managed to solve the problem with the modified code: PlotStyle -> {{Blue, Thin}, {Red, Thin}}, but I still cannot plot proper markers, if I want to keep the blue color for both lines.

And the last question, how to reduce the font size in the legend?

My final and working solution on my OS is the following:

ListPlot[{Table[{(n – 1/2)*1/1000, VelocityU[[1, n]]}, {n, 1, NN}],
Table[{(n – 1/2)*1/1000, VelocityU[[SI, n]]}, {n, 1, NN}]},
Joined -> True, PlotMarkers -> Automatic, Filling -> None,
PlotStyle -> {{Blue, Thin}, {Red, Thin}},
PlotRange -> {{0, (NN)*1/1000}, Automatic}, Frame -> True,
FrameLabel -> {“y [m]”, “U(y) [m/s]”},
GridLines -> {Range[1/1000, 1/100, 0.001], Automatic},
GridLinesStyle -> {{Dashed, Lighter[Gray], Thin}, {Dashed,
Lighter[Gray], Thin}},
FrameTicksStyle -> Directive[FontSize -> 8],
PlotLegends ->
LineLegend[{“U(y, i = 1)”, Row[{“U(y, i = “, ToString[SI], “)”}]},
LegendMarkers -> {Automatic, Automatic}, LabelStyle -> 8]]

Final plot:

=================

  

 

What version are you running?
– rcollyer
Apr 24 ’15 at 12:03

  

 

Mathematica v10.0.1.0
– Mike
Apr 24 ’15 at 12:05

  

 

It’s fixed on 10.0.2 and later, so I’d recommend an upgrade.
– rcollyer
Apr 24 ’15 at 12:18

=================

1 Answer
1

=================

Use the option LineLegend with sub-option LegendMarkers as the setting for PlotLegends:

NN = 15;
data = {Table[{(n – 1/2)*1/1000, 0}, {n, 1, NN}],
Transpose@{Table[(n – 1/2)*1/1000, {n, 1, NN}], -Sort[-RandomInteger[10, NN]]}};

ListPlot[data, Joined -> True, PlotMarkers -> Automatic,
PlotStyle -> {{Blue, Thin}, {Blue, Thin}},
PlotRange -> {{0, (NN)*1/1000}, Automatic}, Frame -> True,
PlotLegends -> LineLegend[{“U(y, i = 1)”, “U(y, i = 400)”},
LegendMarkers -> Automatic]]

  

 

Do you maybe know how to reduce the font size of the legend?
– Mike
Apr 24 ’15 at 11:32

  

 

@Mike, try the option LabelStyle, for example: LineLegend[{Red, Green, Blue}, {“label1”, “label2”, “label3”}, LabelStyle -> 10], or LabelStyle -> Directive[Red, Italic, 20]…
– kglr
Apr 24 ’15 at 11:34

  

 

Your answer does not work in my case. Markers in the legend remain the same. I use Mathematica 10.0.1.0. But it works with PlotLegends -> LineLegend[{“U(y, i = 1)”, “U(y, i = 400)”}, LegendMarkers -> {Automatic, Automatic}]
– Mike
Apr 24 ’15 at 11:37

  

 

@Mike, it could be os differences: the code posted above works both in Version 9.0.1.0 (Windows 8 64-bit) and version 10 (wolfram programming cloud). LegendMarkers -> {Automatic,Automatic} also works in both versions.
– kglr
Apr 24 ’15 at 11:41

  

 

Do you maybe know, how can I write a code with grey background in the comments? I have tried and ‘code’, but nos success.
– Mike
Apr 24 ’15 at 11:53