# Adding a red horizontal line to my plot [duplicate]

I have a list of numbers which I have named "result" and which I modify according to certain rules. At the end of the routine, I plot the list with the command:

ListPlot[result, PlotRange -> Automatic]

I would like to add the horizontal line y=1 (in red) to my plot. Is there a simple way to modify the previous command in order to attain such an effect?

Thanks a bunch for your insightful replies!

## marked as duplicate by Kuba♦Jun 7 '18 at 6:06

• Try InfiniteLine as a Prolog. – Alan Jun 7 '18 at 1:22
• Look up Gridlines – Michael E2 Jun 7 '18 at 1:28
• @Alan: Would you be so kind as to elaborate? – Jamai-Con Jun 7 '18 at 1:57
• I tried "ListPlot[result, PlotRange -> Automatic, Prolog -> {Red, InfiniteLine[{0, 1}, {2, 1}]}]", but I am not getting the desired effect – Jamai-Con Jun 7 '18 at 1:58
• ListPlot[RandomReal[2, {100, 2}], PlotRange -> Automatic, Prolog -> {Red, InfiniteLine[{0, 1}, {1000, 1}]}] – OkkesDulgerci Jun 7 '18 at 3:03

An issue with both InfiniteLine and Gridlines is that the inserted line can significantly overshoot the vertical axis:

There may be a way to correct this [EDIT: There is—see Carl Woll's comment below]; but to avoid having to bother, you could use Show to combine your plot with another plot of y = 1:

Show[ListPlot[RandomReal[2, {100, 2}]], Plot[1, {x, 0, 2}, PlotStyle -> Red]]


• The GridLines extend over the whole plot range, which due to the PlotRangePadding->Automatic default setting extends to about -.05. Use PlotRangePadding->0 to avoid this. – Carl Woll Jun 7 '18 at 5:13

I also believe GridLines is easier

ListPlot[RandomReal[2, {100, 2}], GridLines -> {None, {1}}, GridLinesStyle -> Red]