MathGroup Archive 1999

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

Search the Archive

Re: plotting discontinuity

  • To: mathgroup at smc.vnet.net
  • Subject: [mg17503] Re: plotting discontinuity
  • From: "Allan Hayes" <hay at haystack.demon.co.uk>
  • Date: Mon, 10 May 1999 19:53:13 -0400
  • References: <7h5sh1$h75@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

<mrazek_martin at my-dejanews.com> wrote in message
news:7h5sh1$h75 at smc.vnet.net...
> Can somebody advise me how to plot discontinuity in Mathematica 3.0 ?
> For example: When I type
>
> Plot[1/(x-2),{x,0,4}]
>
> Mathematica plots asymptote (x=2) in the point where the graph has
> discontinuity. I'm in bad need of elimination of this asymptote but I
> haven't invented how. For example in other systems it is possible
> to write discontinuity=true and the program plots it in this way. Which
> option is it in Mathematica ?
>
> martin
>
>
> --== Sent via Deja.com http://www.deja.com/ ==--
> ---Share what you know. Learn what you don't.---
>

Martin

Here is one way, from my column How and Why?, Mathematica in Education and
Research Volume 7, No 2, Spring 1998, p 41.

We often wish to avoid the sort of spurious vertical features shown in

plt = Plot[Tan[x], {x, -2Pi, Pi}];

Using Split we can write a function that operates on Graphics objects  and
splits lines at points where the absolute slope gets big,

 DeleteVerticals[gr_Graphics, slopeMax_] :=
 gr /. Line[lst_] :>
        Map[Line,
       Split[lst, Abs[Divide @@ Reverse[#1 - #2]] < slopeMax &],
          1];

The pure function for the absolute slope of the join of successive points on
the line is based on

Abs[Divide @@ Reverse[{x1, y1} - {x2, y2}]]

Test this on the previous plot.

Show[DeleteVerticals[plt, 5000]]

This can be refined in many ways:
1. For example to act more automatically by getting a values for slopeMax
based on the perceived slope rather than underlying mathematical slope  -
for this we would need to find the plot range and aspect ratio actually
used, this can be done with FullOptions.
2. One-point lines like, Line[{{0,0}}], may be made by DeleteVerticals.
These are displayed as points. They could be deleted with the help of
DeleteCases - maybe used in as option to DeleteVerticals.



  • Prev by Date: Re: AND... How can I tell M to have the same spaces on the x- AND the y-axis?
  • Next by Date: Default printer: 3.0 X-windows Solaris
  • Previous by thread: plotting discontinuity
  • Next by thread: Re: plotting discontinuity