MathGroup Archive 2008

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

Search the Archive

Re: How to plot discontinuous functions?


f[x_] := If[x < 1, 1, 2];
Plot[f[x], {x, 0, 2},
 PlotRange -> {0, 3}, Exclusions -> 1]


Bob Hanlon

---- Aaron Fude <aaronfude at gmail.com> wrote: 
> Hi,
> 
> If a function is defined via If, then when plotted it does not
> acknowledge the discontinuity. E.g.
> 
> f[x_] := If[x < 1, 1, 2];
> Plot[f[x], {x, 0, 2}, PlotRange -> {0, 3}]
> 
> Defined via Piecewise, it does, but in my experience, not always:
> f[x_] := Piecewise[{{{1, 1}, x < 1}}, {2, 2}];
> Plot[f[x][[1]], {x, 0, 2}, PlotRange -> {0, 3}]
> 
> How do I make the Plot function try to acknowledge the discontuity by
> not connecting the left limit and the right limit?
> 
> Thanks,
> 
> Aaron
> 



  • Prev by Date: Re: Ticks question
  • Next by Date: Re: A set of several questions
  • Previous by thread: Re: Possible Bug in Mathematica 6
  • Next by thread: Re: How to plot discontinuous functions?