Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1998
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1998

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

Search the Archive

Re: Plotting w/o artifacts at discontinuities


  • To: mathgroup@smc.vnet.net
  • Subject: [mg12156] Re: Plotting w/o artifacts at discontinuities
  • From: nicolas.martignoni@unifr.ch (Nicolas Martignoni)
  • Date: Mon, 27 Apr 1998 01:46:40 -0400
  • Organization: Unisource Business Networks
  • References: <6hpeed$dck@smc.vnet.net>

In article <6hpeed$dck@smc.vnet.net>, bic@cgl.ucsf.EDU (Bruce Cohen
%FEC) 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
>advance. 
>
>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.
>
>
>Thanks.
>
>-Bruce
>        Bruce Cohen                    |  INTERNET: bic@cgl.ucsf.edu
>        Lick-Wilmerding High School    |           
>bic@lick.pvt.k12.ca.us
>        755 Ocean Avenue               |  VOICE:    (415) 333-4021
>        San Francisco, CA  94112       |  FAX:      (415) 333-9443 -- 
>        Bruce Cohen                    |  INTERNET: bic@cgl.ucsf.edu
>        Lick-Wilmerding High School    |           
>bic@lick.pvt.k12.ca.us
>        755 Ocean Avenue               |  VOICE:    (415) 333-4021
>        San Francisco, CA  94112       |  FAX:      (415) 333-9443

You could use this program. It could certainly be improved, but it
works. However it doesn't treat the plotting of a list of functions.

NewPlot[f_, range:{x_, __}, opts___] := 
  
  Module[{theplot, pos2 = {}, pos1 = {1}, current = counter = 0},
    
    theplot = Plot[f, range, 
        DisplayFunction -> Identity, opts];
    
    points = theplot[[1,-1,1,1]];
    
    Scan[
      (If[# current<0 && Abs[#] + Abs[current] > 10^5,
      AppendTo[pos2, counter]; AppendTo[pos1, counter+1]];
      counter++; 
      current=#)&,
      Map[Last, points]
    ];
    
    AppendTo[pos2, counter];
    
    points = MapThread[Take[points, {#1, #2}]&, {pos1, pos2}];
    
    theplot[[1,-1]] = Map[Line, points];
    
    Show[theplot, DisplayFunction -> $DisplayFunction] ]

Regards,

Nicolas

**************************************************************** Nicolas
Martignoni   Voice    ++ 41 26 424 36 03 Route du Levant 2    Email   
mailto:nicolas.martignoni@unifr.ch CH-1700 Fribourg     Location
+46d48m 07d09m East
****************************************************************



  • Prev by Date: Re: 1+Cos[x]Cosh[x]==0 ?
  • Next by Date: Re: Boundary cond. at Infinity
  • Prev by thread: Plotting w/o artifacts at discontinuities
  • Next by thread: Re: Plotting w/o artifacts at discontinuities