MathGroup Archive 2000

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

Search the Archive

Re: avoid spurious vertical segment in step function plot

  • To: mathgroup at smc.vnet.net
  • Subject: [mg23371] Re: [mg23327] avoid spurious vertical segment in step function plot
  • From: BobHanlon at aol.com
  • Date: Thu, 4 May 2000 02:59:39 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

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


  • Prev by Date: RE: Problem with Plot and Ticks-function
  • Next by Date: Re: Union in Mathematica versions 3 and 4
  • Previous by thread: Re: avoid spurious vertical segment in step function plot
  • Next by thread: Re: avoid spurious vertical segment in step function plot