Re: how to draw a vertical line

• To: mathgroup at smc.vnet.net
• Subject: [mg26067] Re: how to draw a vertical line
• From: Robert Tartarin <tartarin at zeus.sc-eco.univ-nantes.fr>
• Date: Wed, 22 Nov 2000 01:55:55 -0500 (EST)
• Sender: owner-wri-mathgroup at wolfram.com

>> How to draw a vertical line ?
>> [question from lysov at paloma.spbu.ru]

>In article <8v7khv\$b17 at smc.vnet.net>, Robert Tartarin
><tartarin at zeus.sc-eco.univ-nantes.fr> wrote:
>
I know 3 solutions for a vertical line with x* as abcisse:

>
>Is Epilog a fourth (and maybe the neatest) solution?
"A. E. Siegman" <siegman at stanford.edu>

Right, you got a fourth solution; you can write, for example:

Plot[Sin[x], {x, 0, 10}, Epilog -> {Line[{{4, -1}, {4, 1}}]}] ;

Meanwhile, Epilog uses the Line primitive, so you get into the same trouble
as for using

Plot [ { {x*, maxyvalue}, {x*,minyvalue}}, {xdomain} ] . or
Graphics [ Line [ { {x*, maxyvalue}, {x*,minyvalue} } ]  within Show [ ]

you have to define maxyvalue and minyvalue according to the values of some
other function on the domain.  In other words with :
Plot[Sin[x], {x, 0, 10}, Epilog -> {Line[{{4, -1}, {4, 1}}]}] , how do you
know that -1,+1 are the right y-values?
Gridlines knows it!

One might think also to use Scaled in the following way :

Plot[Sin[x], {x, 0, 10},
Epilog -> {Line[{Scaled[{4/10, -1}], Scaled[{4/10, 1}]}]}];
PlotRange[%]

Zooming on x = 4, you will observe that the vertical line is drawn left
from x = 4. Because the Scaled command is applied to the DIMENSIONS OF THE
GRAPH (given by PlotRange) and NOT THE DOMAIN VALUES xdomain.

To get the graphic right you must read through AbsoluteOptions (formerly
FullOptions), or better use directly Plot Range :

for absolute coordinates

Plot[Sin[x], {x, 0, 10}, DisplayFunction -> Identity];
Plot[Sin[x], {x, 0, 10},
Epilog -> {Line[{{4, PlotRange[%][[2, 1]]}, {4,
PlotRange[%][[2, 2]]}}]}];

or alternatively, for relative coordinates

x* = 4; xmin = 0; xmax = 10;
Plot[Sin[x], {x, xmin, xmax}, DisplayFunction -> Identity];
xrelative =
Abs[(x* - PlotRange[%][[1, 1]])]/
Abs[(PlotRange[%][[1, 1]] - PlotRange[%][[1, 2]])]
Plot[Sin[x], {x, xmin, xmax},
Epilog -> {Line[{Scaled[{xrelative, -1}], Scaled[{xrelative, 1}]}]}];

See, you have either to compute y-values if you use Epilog with absolute
coordinates, or compute the right x-value if you use Epilog with relative
coordinates.

Unless you use Gridlines....

Robert Tartarin
5 place R. Salengro
44000 Nantes
02 40 48 47 77

MacOS 8.6, Eudora L. 313, Word 6 et 98 [préférence pour les formats TEXT ou
RTF]

• Prev by Date: Re: PageWidth mystery
• Next by Date: Re: NDSolve help needed for nonlinear eq.
• Previous by thread: Re: how to draw a vertical line
• Next by thread: PageWidth mystery