Re: gaps in plot of piecewise function
- To: mathgroup at smc.vnet.net
- Subject: [mg108228] Re: gaps in plot of piecewise function
- From: gekko <pfalloon at gmail.com>
- Date: Thu, 11 Mar 2010 06:35:42 -0500 (EST)
- References: <hn7vst$a20$1@smc.vnet.net>
On Mar 10, 10:30 pm, Benjamin Hell <h... at exoneon.de> wrote:
> Hi,
> I want to plot a piecewise function, but I don't want any gaps to appear
> at the junctures. An easy example is:
>
> s[x_] := Piecewise[{{-Sqrt[2]/2*Sqrt[-x + 0.5] + 2, x < 0.5}, {2, x >=
=
> 0.5}}];
> Plot[s[x], {x, 0, 1}]
>
> It should be clear, that the piecewise function defined above is
> continuous, even at x=0.5. So there should not be any gaps appearing in
> the plot, but they do. Maybe it's a feature of mathematica, but
> nevertheless I want to get rid of the gaps. Any suggestions on how to
> achieve that.
>
> Thanks in advance.
It looks like the point x == 0.5 is being picked up as a possible
discontinuity and so the plot does not attempt to join at this point.
You can disable this using the Exclusions option:
Plot[s[x], {x,0,1}, Exclusions->None]
Cheers, P.