MathGroup Archive 1998

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

Search the Archive

Re: Plotting w/o artifacts at discontinuities

Try something like this. This won't work for every function, but it will
handle simple expressions like your example.

discPlot[func_, {x_, xmin_, xmax_}, opts___] := 
   Module[{poles, ranges, nbr, p}, 
    poles = x /. Solve[1/func == 0, x]; 
     ranges = 
      ({x, #1[[1]], #1[[2]]} & ) /@ 
          Select[poles, xmin < #1 < xmax & ], xmax}], 2, 1]; 
     nbr = Length[ranges]; 
     Table[p[k] = 
       Plot[func, Evaluate[ranges[[k]], opts], 
        DisplayFunction -> Identity], {k, nbr}]; 
     Show[Table[p[k], {k, nbr}], 
      DisplayFunction -> $DisplayFunction]; ]; 

discPlot[1/((1 + x)*(x - 1)*(x - 1/2)), {x, -2, 1}, AxesLabel -> {"x",

discPlot[1/(x^2+3x+1), {x, -3, 0}]

Bob Hanlon

In a message dated 4/25/98 4:25:13 AM, bic@cgl.ucsf.EDU wrote:

>I would like to be able to get plots that do not have artifacts from
>discontinuities without having to know where the problem[s] will be in
>For example, I would like to be able to say
>	Plot[1/(1+x), {x,-2,1}]
>and get a graph without the vertical line at x==-1.  Though 
>	p1=Plot[1/(1+x), {x,-2,-1}, DisplayFunction->Identity];
>	p2=Plot[1/(1+x), {x,-1,1}, DisplayFunction->Identity];
>	Show[p1,p2, DisplayFunction->$DisplayFunction]; does the trick, it
>requires my anticipation of the problem at x==1.

  • Prev by Date: Re: Frontend problems under NT 4.0
  • Next by Date: Re: Sqrt Problems
  • Prev by thread: Re: Plotting w/o artifacts at discontinuities
  • Next by thread: 2D Heat Equation w/ NDSolve