Re: question about plot
- To: mathgroup at smc.vnet.net
- Subject: [mg69602] Re: [mg69589] question about plot
- From: Bob Hanlon <hanlonr at cox.net>
- Date: Sun, 17 Sep 2006 06:57:27 -0400 (EDT)
- Reply-to: hanlonr at cox.net
plotDisc[args___] := Module[{p}, p = Plot[args, DisplayFunction -> Identity] //. (Line[{s___, {x1_, y1_}, {x2_, y2_}, e___}]/; (Abs[(y2-y1)/(x2-x1)] > 10^3 && Sign[y1] != Sign[y2])):> Sequence[Line[{s, {x1, y1}}], Line[{{x2, y2}, e}]]; Show[p, DisplayFunction -> $DisplayFunction]]; h[x_] := x Tan[x]; plotDisc[h[x], {x, 0, 4Pi}]; Bob Hanlon ---- dimmechan at yahoo.com wrote: > ***Hello to all. > > ***I have a simple function > > ln[156]:=Quit > > ln[1]:=h[x_]:=x Tan[x] > > ***Here its Plot > > In[4]:=Plot[h[x],{x,0,Pi}] > > ***Plot has incorrectly connected the points at p/2. > > ***There are two approaches to deal with this bug. > > ***The first is to use a Block structure along with Show > > ln[6]:=Block[{$DisplayFunction = Identity}, g1 = Plot[h[x], {x, 0, > Pi/2}]; > ln[7]:=g2 = Plot[h[x], {x, Pi/2, Pi}]]; > Show[g1, g2, DisplayFunction \[Rule] $DisplayFunction] > > ***The other is to define your code. Here is my attempt: > > In[12]:= > plotdisc[f_,a_,b_,x0_,opts___]:=Show[Map[Plot[f,{x,#[[1]],#[[2]]}, > > DisplayFunction\[Rule]Identity,opts]&,Delete[Partition[{a,x0-10^-8,x0+10^-8,b},\ > 2,1],2]],DisplayFunction\[Rule]$DisplayFunction] > > In[13]:=plotdisc[h[x],0,Pi,Pi/2,Axes->False,Frame->True] > > ***However my plotdisc[] function has the disadvantage that can deal > with only one > discontinuity each time. > > ***How can I modify it (or if I can't, I look for another more elegant > code) so that to deal with > any number of discontinuities. > > ***In other words I look for a function (if mine cannot be modified) > which for example has the same output with > > ln[16]:=Block[{$DisplayFunction = Identity}, gg1 = plotdisc[h[x], 0, > Pi, Pi/2]; > gg2 = plotdisc[h[x], Pi, 2Pi, 3Pi/2]]; > ln[17]:=Show[gg1, gg2, DisplayFunction \[Rule] $DisplayFunction] > > > ***Thanks in advance for any assistance. >