# Specify color when plotting using Graphics

If I have the following:

p1 = ListPlot[data];
p2 = Graphics@Line[{{65, 0.056}, {80, 0.056}}];


How can I plot both p1 and p2 together specifying the color for each of them. For instance, I want p1 to be green and p2 to be red. I am using the following

Show[{p1, p2}, PlotStyle -> {Green, Red}]


but this does not work for those colors.

EDIT: How can I add legends for each of them? say "legend1" for the p1 and "legend2" for the p2

Thanks,

• ListPlot[data, PlotStyle -> Green] and Graphics[{Red, Line[...]}] should do it. You can't use Show to do styling, it's just for putting graphics together. Note that ListPlot also has Epilog and Prolog options that you can use to draw the line. May 27 '20 at 17:54
• @C.E. Thanks! I am using p1=ListPlot[data, PlotStyle -> Green] p2 = Graphics[{Red, Line[{65, 0.056}, {80, 0.056}]}] but It still does not work. Is there any sintax error in p2?. Finally I use Show[p1, p2]
– John
May 27 '20 at 18:02
• Yes, it should be Line[{{65, 0.056}, {80, 0.056}}] May 27 '20 at 18:04
• @C.E. Thank you! That works !
– John
May 27 '20 at 18:08
• @C.E.: To be fair, some options that users might mentally lump in with "styling" (PlotRange, Axes, PlotLabel, Ticks, etc.) can be passed to Show as options. So I wouldn't say that it's strictly true that Show is "just for putting graphics together". May 27 '20 at 18:41

data = Transpose[{Range[60, 80], Sin[N@Range[60, 80]]}];

ListLinePlot[
{data, {{65, 0.056}, {80, 0.056}}},
PlotStyle -> {Green, Red},
PlotLegends -> {"legend1", "legend2"}
]

• Thanks!!! This works !
– John
May 27 '20 at 18:33
• Good! Always glad to help. =) May 27 '20 at 18:34