Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

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>
  • Reply-to: HPR <read at math.uvm.edu>

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}]


-- 
Helen Read
University of Vermont


  • Prev by Date: Re: Ten chess-players...
  • Next by Date: Re: ODE with in a piece wise plot
  • Previous by thread: Re: How create vertical line using Plot?
  • Next by thread: ReplaceAll and rules from a list v7.0