       Re: How create vertical line using Plot?

• To: mathgroup at smc.vnet.net
• Subject: [mg104239] Re: How create vertical line using Plot?
• From: Helen Read <hpr at together.net>
• Date: Sun, 25 Oct 2009 01:03:58 -0400 (EDT)
• References: <hbu7s7\$7ic\$1@smc.vnet.net>

```davef wrote:
> How can I create a vertical line using the Plot command?
>
> I can hack it using "y" = very big number times "x" but is there a
> more elegant way to do it?

A vertical line is not a function, so Plot won't plot it. You can use
ContourPlot or ParametricPlot to plot a vertical line, or use the
Graphics primitive Line. For example, each of the following will plot
the line x=3.

ContourPlot[x == 3, {x, -5, 5}, {y, -5, 5}]

ParametricPlot[{3, t}, {t, -5, 5}, PlotRange -> 5]

Graphics[Line[{{3, -5}, {3, 5}}], PlotRange -> 5, Axes -> True]

Use Show to combine any of the above with other plots. For instance:

For instance:

plot1 = Plot[x^2, {x, -5, 5}];
plot2 = ParametricPlot[{3, t}, {t, -5, 16}, PlotStyle -> Red];
Show[{plot1, plot2}, PlotRange -> Automatic]

Or use Epilog to add Graphics primitives to a plot. For instance:

Plot[x^2, {x, -5, 5}, Epilog -> {Red, Line[{{3, -5}, {3, 16}}]},
PlotRange -> {-5, 25}]

--