Re: avoid spurious vertical segment in step function plot

*To*: mathgroup at smc.vnet.net*Subject*: [mg23395] Re: [mg23327] avoid spurious vertical segment in step function plot*From*: Murray Eisenberg <murray at math.umass.edu>*Date*: Fri, 5 May 2000 02:07:35 -0400 (EDT)*Organization*: Mathematics & Statistics, Univ. of Mass./Amherst*References*: <8erac6$hk2@smc.vnet.net>*Sender*: owner-wri-mathgroup at wolfram.com

Another interesting and useful solution. Thanks. BobHanlon at aol.com wrote: > > This may look familiar ... > > plt = Plot[ > UnitStep[x] - UnitStep[x - 1] + UnitStep[x - 2] - > UnitStep[x - 3], {x, -1, 4}, Frame -> True, Axes -> False, > PlotRange -> {-.2, 1.2}]; > > threshold = 0.5; > > Show[plt //. {Line[{start___, {x1_, y1_?(# < threshold &)}, {x2_, > y2_?(# > threshold &)}, end___}] :> > Sequence[Line[{start, {x1, y1}}], Line[{{x2, y2}, end}]], > Line[{start___, {x1_, y1_?(# > threshold &)}, {x2_, > y2_?(# < threshold &)}, end___}] :> > Sequence[Line[{start, {x1, y1}}], Line[{{x2, y2}, end}]]}]; > > There is probably some way to work these two rules into one; however, it > didn't leap immediately to mind. > > In a message dated 5/2/2000 1:01:33 AM, murray at math.umass.edu writes: > > >Several packages available from MathSource deal with eliminating the > >spurious parts of plots of discontinuous functions across vertical > >asymptotes. > > > >Is there some simple way of dealing with the similar problem of > >eliminating the spurious vertical line segment in plotting a function > >with jumps -- for example, in the following? > > > > Plot[UnitStep[x], {x, -1, 1}] > > > > Bob > > BobHanlon at aol.com -- Murray Eisenberg murray at math.umass.edu Mathematics & Statistics Dept. phone 413 549-1020 (H) Univ. of Massachusetts 413 545-2859 (W) Amherst, MA 01003-4515