# Making a Plot legend containing both markers and lines?

I am trying to make a legend comprised of both the plot's marker symbol and a line. Specifically, I am hoping to have a legend that looks like the line is crossing through the marker. My current code only shows a line:

Function1 = Exp[-0.03*g100];

Plot1 = Plot[Function1, {g100, 0.000001, 100}, ImageSize -> Large, PlotRange -> {0, 1},
Frame -> {{True, False}, {True, False}},
PlotLegends ->
Placed[{Style["test", FontSize -> 20,
Black]}, {0.9, 0.85}]];
Plot2 = ListPlot[
Thread[{Range[1/20, 1, 1/20], {0.228, 0.379, 0.433, 0.515, 0.557,
0.567, 0.621, 0.624, 0.637, 0.661, 0.663, 0.655, 0.613, 0.601,
0.578, 0.512, 0.484, 0.459, 0.399, 0.38}}], DataRange -> {0, 1},
PlotMarkers -> {"\[FilledCircle]", 15}, PlotRange -> {0, 0.4}];
Show[Plot1, Plot2]


Is there a solution to this problem, despite the fact that the markers are associated with a data set that is independent of Function1?

• use PlotLegends -> Placed[LineLegend[{Style["test", FontSize -> 20, Black]}, LegendMarkers -> {Automatic, 12}], {0.9, 0.85}] in Plot[...]?
– kglr
Apr 16, 2022 at 3:13
• @kglr Thank you so much!! Apr 16, 2022 at 4:01

For me, the obvious step of adding a PlotLegends argument to Plot2 does what I think you are asking for

Function1 = Exp[-0.03*g100];

Plot1 = Plot[Function1, {g100, 0.000001, 100}, ImageSize -> Large,
PlotRange -> {0, 1}, Frame -> {{True, False}, {True, False}},
PlotLegends ->
Placed[{Style["test", FontSize -> 20, Black]}, {0.9, 0.85}]];
Plot2 = ListPlot[
Thread[{Range[1/20, 1, 1/20], {0.228, 0.379, 0.433, 0.515, 0.557,
0.567, 0.621, 0.624, 0.637, 0.661, 0.663, 0.655, 0.613, 0.601,
0.578, 0.512, 0.484, 0.459, 0.399, 0.38}}], DataRange -> {0, 1},
PlotMarkers -> {"●", 15},
PlotLegends ->
Placed[{Style["test 2", FontSize -> 20, Black]}, {0.9, 0.85}],
PlotRange -> {0, 0.4}];
Show[Plot1, Plot2]