MathGroup Archive 1995

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

Search the Archive

Re: Plotting Piecewise Functions with Discontinuites

  • To: mathgroup at
  • Subject: [mg1974] Re: [mg1941] Plotting Piecewise Functions with Discontinuites
  • From: Allan Hayes <hay at>
  • Date: Wed, 30 Aug 1995 01:51:12 -0400

"Paul J. Simonich" <simonichpj%dfms%usafa at>
in [mg1941] Plotting Piecewise Functions with Discontinuites
wishes to avoid Mathematica drawing vertical asymptotes.

Here is a way in which you don't need to know where the asymptotes  
are.The third entry controls the slope beyond which the line  
elements are to be removed: the default is 25 times the slope of the  
line from bottom left to top right of the bounding rectangle in  
user coordinates.
The treatment can be varied by, for example, adding an option or an  
entry to Plot (though the former way is quite tricky - see  
We can also arrange for the graphics object produced to contain
multi-point lines instead of two point line segments.

Allan Hayes
hay at


PlotNA[f_,{x_,a_,b_},n:(_Integer?Positive):25, opts___?OptionQ] :=
Module[ {graph,ar,graphNA,pairs},
   graph = Plot[f, {x,min,max}, DisplayFunction->Identity,opts];
   ar = Divide@@Reverse[FullOptions[graph,PlotRange].{-1,1}];
   graphNA =
      graph/.Line[lst_] :>
	 (pairs = Partition[lst, 2, 1];
	     p_/;Greater@@(Abs/@(Subtract@@p){n ar,1}) :> Line[p]
   Show[graphNA, DisplayFunction -> $DisplayFunction]

  • Prev by Date: Re: Re: question about nest
  • Next by Date: Re: Question: how to get Sin[n*Pi]=0 (n integer)
  • Previous by thread: Re: Plotting Piecewise Functions with Discontinuites
  • Next by thread: Working with & plotting elevation represented as a 2D array