# Legends in a combined Plot and ListPlot

This question is related to the previously asked question Legends in combined Plot and ListPlot.

Since Mathematica 9 introduced new option PlotLegends, I was tempted to use built-in facility. (With the previous versions, I used the LevelScheme package).

Consider a data set

A = {#, #^2} & /@ Range[100];
B = {#, #^1.8} & /@ Range[100];


and its theoretical prediction

A1 = x^2;
B1 = x^1.8;


I want to plot them together using ListPlot and Plot, respectively. And show them together with a single, combined legend.

Also, I want to have user defined markers (e.g, filled-diamond, size = 15, joined -> false and so on) and set the style of the plot (e.g., Red, Thickness[0.01], Dashed and so on).

I wonder if these requirements can be achieved by the built-in PlotLegends in Mathematica 9.

### Edit

The code below is what I tried, but I could not get the desired result.

MakeExponent[x_Integer] := "\*SuperscriptBox[10," <> ToString[x] <> "]"
tick = {10^#, MakeExponent[#]} & /@ Range[-10, 10, 1];

A = {1/#, #^2} & /@ Range[100];
B = {1/#, #^1.5 - 1} & /@ Range[100];
A1 = {1/#, #^2} & /@ Range[100];
B1 = {1/#, #^1.5 - 1} & /@ Range[100];
ALegend = Style[ "Legend A", 12, Black, FontFamily -> "Courier"];
BLegend = Style[ "Legend B", 12, Black, FontFamily -> "Helvetica"];
A1Legend = Style[ "Legend A1", 12, Black, FontFamily -> "Courier"];
B1Legend = Style[ "Legend B1", 12, Black, FontFamily -> "Courier"];
AMarker  = Style["\[FilledCircle]", 10, Orange];
BMarker  = Style["\[FilledDiamond]", 10, Purple];
A1Marker  = Style["\[LongDash]", 15, Blue];
B1Marker  = Graphics[Line[{{0, 0}, {1, 0}}]];
XLabel = Style[ Sqrt[x^2], 17];
YLabel = Style[t^2 , 17];


And then I tried

pic1 = ListLogLogPlot[ {A, B, A1, B1},
Axes -> False,
Frame -> True,
Joined -> {False, False, True, True},
PlotStyle -> {, , Blue, Red},
FrameLabel -> {XLabel, YLabel} ,
PlotMarkers -> {AMarker, BMarker, ,},
PlotLegends ->
Placed[
PointLegend[
{ALegend, BLegend, A1Legend, B1Legend},
LegendMarkers -> {AMarker, BMarker, A1Marker, B1Marker},
LegendMarkerSize -> {30, 10},
], {0.8, 0.7}
],
FrameTicks -> {{tick, None}, {tick, None}},
FrameTicksStyle -> 16
]

• Try removing the extra comma after the LegendMarkerSize option Nov 24, 2013 at 16:21

A few minor errors corrected (mostly extra commas):

MakeExponent[x_Integer] := "\*SuperscriptBox[10," <> ToString[x] <> "]"
tick = {10^#, MakeExponent[#]} & /@ Range[-10, 10, 1];

A = {1/#, #^2} & /@ Range[100];
B = {1/#, #^1.5 - 1} & /@ Range[100];
A1 = {1/#, #^2} & /@ Range[100];
B1 = {1/#, #^1.5 - 1} & /@ Range[100];
ALegend = Style["Legend A", 12, Black, FontFamily -> "Courier"];
BLegend = Style["Legend B", 12, Black, FontFamily -> "Helvetica"];
A1Legend = Style["Legend A1", 12, Black, FontFamily -> "Courier"];
B1Legend = Style["Legend B1", 12, Black, FontFamily -> "Courier"];
AMarker = Style["\[FilledCircle]", 10, Orange];
BMarker = Style["\[FilledDiamond]", 10, Purple];
A1Marker = Style["\[LongDash]", 15, Blue];
B1Marker = Style["\[LongDash]", 15, Red];
XLabel = Style[Sqrt[x^2], 17];
YLabel = Style[t^2, 17];
pic1 = ListLogLogPlot[{A, B, A1, B1}, Axes -> False, Frame -> True,
Joined -> {False, False, True, True}, PlotStyle -> {Blue, Red},
FrameLabel -> {XLabel, YLabel}, PlotMarkers -> {AMarker, BMarker},
PlotLegends ->
Placed[PointLegend[{ALegend, BLegend, A1Legend, B1Legend},
LegendMarkers -> {AMarker, BMarker, A1Marker, B1Marker},
LegendMarkerSize -> {30, 10}], {0.8, 0.7}],
FrameTicks -> {{tick, None}, {tick, None}}, FrameTicksStyle -> 16]