Re: How to plot discontinuous functions?

*To*: mathgroup at smc.vnet.net*Subject*: [mg90172] Re: How to plot discontinuous functions?*From*: "David Park" <djmpark at comcast.net>*Date*: Tue, 1 Jul 2008 07:00:41 -0400 (EDT)*References*: <g4a6tv$8uh$1@smc.vnet.net>

For something like this you could use a UnitStep. Plot[1 + UnitStep[x - 1], {x, 0, 2}, PlotRange -> {0, 3}] Your second case will work if you use the Exclusions option. f[x_] := Piecewise[{{{1, 1}, x < 1}}, {2, 2}]; Plot[f[x][[1]], {x, 0, 2}, PlotRange -> {0, 3}, Exclusions -> {1}] Exclusions will usually work for these cases. But if worst comes to worst, or things are inconvenient, the Presentations package has (left over from pre Version 6 days) the SplitLineOn... rules. Needs["Presentations`Master`"] Draw2D[ {Draw[f[x][[1]], {x, 0, 2}] /. SplitLineOnVertical[.6]}, AspectRatio -> .5, PlotRange -> {0, 3}, Axes -> True] -- David Park djmpark at comcast.net http://home.comcast.net/~djmpark/ "Aaron Fude" <aaronfude at gmail.com> wrote in message news:g4a6tv$8uh$1 at smc.vnet.net... > 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 >