From: erkutsonmez on
Hi All,

I am plotting a piecewise function. Mathematica is joining the step
points with vertical lines. How can I get rid of these vertical lines
which makes my plot ugly. I tried Exclusions option but did not help.

To be more specific I have the following plot:

Plot[Piecewise[{{1,
First[Max[EBProfit1server1years1per, EBProfit2server1years1per] -
CONProfit1per] > 0}}, 0], {x, 0,
2}, PlotStyle -> {{Black, Thickness[0.004]}},
AxesStyle -> Directive[Thick, 24, Bold], AxesOrigin -> {0, 0},
PlotPoints -> 10000, MaxRecursion -> 15, AspectRatio -> Automatic]

where EBProfit1server1years1per, EBProfit2server1years1per, and
CONProfit1per are also predefined piecewise functions. When I run this
plot I see that mathematica is joining the step points with vertical
lines. How can I avoid these vertical lines.

Thanks for the help.
Erkut

From: David Park on
A regular Piecewise Plot of a discontinuous function does not draw the
vertical lines. So we would have to know more.

1) It is better if you can post evaluable code that illustrates the problem.

2) If you have trouble with a plot, and the function being plotted is quite
involved, then it might help to look at the function outside the plot to
better understand its characteristics and perhaps simplify it.
(PiecewiseExpand?) Also it may be more efficient if a plot function can be
calculated and defined first outside of the plot.

3) Using 10000 plot points and MaxRecursion 15 is pure brute force and there
is probably a simpler answer.

4) The Presentations package has routines SplitLineOnDistance,
SplitLineOnSlope and SplitLineOnVertical that are sometimes convenient for
eliminating such "return line segments", but if we knew your function better
it might be possible to use the regular Exclusion option. I'm not certain
why the default Exclusions value is not working, but Mathematica is not
recognizing the discontinuities and we can't know why unless we know more
about your function.


David Park
djmpark(a)comcast.net
http://home.comcast.net/~djmpark/



From: erkutsonmez [mailto:erkuts(a)gmail.com]

Hi All,

I am plotting a piecewise function. Mathematica is joining the step
points with vertical lines. How can I get rid of these vertical lines
which makes my plot ugly. I tried Exclusions option but did not help.

To be more specific I have the following plot:

Plot[Piecewise[{{1,
First[Max[EBProfit1server1years1per, EBProfit2server1years1per] -
CONProfit1per] > 0}}, 0], {x, 0,
2}, PlotStyle -> {{Black, Thickness[0.004]}},
AxesStyle -> Directive[Thick, 24, Bold], AxesOrigin -> {0, 0},
PlotPoints -> 10000, MaxRecursion -> 15, AspectRatio -> Automatic]

where EBProfit1server1years1per, EBProfit2server1years1per, and
CONProfit1per are also predefined piecewise functions. When I run this
plot I see that mathematica is joining the step points with vertical
lines. How can I avoid these vertical lines.

Thanks for the help.
Erkut



From: Helen Read on
On 6/8/2010 7:09 AM, erkutsonmez wrote:
> Hi All,
>
> I am plotting a piecewise function. Mathematica is joining the step
> points with vertical lines. How can I get rid of these vertical lines
> which makes my plot ugly. I tried Exclusions option but did not help.
>
> To be more specific I have the following plot:
>
> Plot[Piecewise[{{1,
> First[Max[EBProfit1server1years1per, EBProfit2server1years1per] -
> CONProfit1per]> 0}}, 0], {x, 0,
> 2}, PlotStyle -> {{Black, Thickness[0.004]}},
> AxesStyle -> Directive[Thick, 24, Bold], AxesOrigin -> {0, 0},
> PlotPoints -> 10000, MaxRecursion -> 15, AspectRatio -> Automatic]
>
> where EBProfit1server1years1per, EBProfit2server1years1per, and
> CONProfit1per are also predefined piecewise functions. When I run this
> plot I see that mathematica is joining the step points with vertical
> lines. How can I avoid these vertical lines.

It would help if you post a specific example that demonstrates the
behavior, that others can copy/paste into Mathematica and evaluate,
instead of having to try to come with their own example. I tried to
reproduce what you are talking about with Piecewise, and finally gave up.

Anyway, use Exclusions to exclude the step points.

f[x_] := Abs[x^2 - 4]/(x^2 - 4)

Plot[f[x], {x, -5, 5}]

Plot[f[x], {x, -5, 5}, Exclusions -> {-2, 2}]



--
Helen Read
University of Vermont