How to plot multiple horizontal lines? [duplicate]

Possible Duplicate:
How to insert guide-lines in graphics without specifying range?

How to plot multiple horizontal lines?

For instance, I want to plot 3 horizontal lines: y=-1, y=0 and y=1. Seems to be a pretty simple thing, but I couldn't figure out how; although I've searched all over the documentation center.

• check out GridLines with some of the examples of gridlines with specific values. – Mike Honeychurch Dec 7 '12 at 5:16
• @LeiChen Can you add more detail to your question? Do you want a graphic only with lines or do you want the lines in a e.g. plot of a function as grid? – halirutan Dec 7 '12 at 5:30
• @halirutan I just want multiple horizontal lines. How to plot Function with grid is well explained by the documentation center. Thanks! – Lei Chen Dec 7 '12 at 5:35
• Drawing lines is also pretty well covered in the manual. What was the problem you faced there? – Sjoerd C. de Vries Dec 7 '12 at 6:59

If you just want to draw Lines, than you can create your own Graphics. I hope the code is self-explanatory

Graphics[{
Line[{{0, -1}, {1, -1}}],
Line[{{0, 0}, {1, 0}}],
Line[{{0, 1}, {1, 1}}]
}]


• Thanks!! You just solved something I wasn't able to figure out a whole night! – Lei Chen Dec 7 '12 at 5:44
• @LeiChen Then please take some minutes to read the FAQ. Especially, you should understand that we have a voting system here and the -1 infront of your question means in your case: "your question is not explained in detail so that it is not clear what you mean". You can always edit your question and you should learn what up/downvoting and accepting is! – halirutan Dec 7 '12 at 5:47
• even that is easier to do with gridLines -- Graphics[{}, GridLines -> {None, {-1, 0, 1}}] – Mike Honeychurch Dec 7 '12 at 5:51

The long way round:

Plot[
{
Evaluate[y = -1],
Evaluate[y = 0],
Evaluate[y = 1]
}, {x, -10, 10}, PlotStyle -> {Thick}, PlotRange -> {-10, 10}]


• Why not just Plot[{-1, 0, 1}, ...]? – Rahul Dec 7 '12 at 15:57
• :) I was trying to get as close to the question as possible... – cormullion Dec 7 '12 at 16:07