Re: Plotting a step function with the origin indicated

• To: mathgroup at smc.vnet.net
• Subject: [mg21272] Re: Plotting a step function with the origin indicated
• From: "Allan Hayes" <hay at haystack.demon.co.uk>
• Date: Tue, 21 Dec 1999 03:46:53 -0500 (EST)
• References: <83klp2\$1f8@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```aey,
This really has nothing to do with step functions.
The ranges of the axes are determined by the plot range; which is computed
taking into account the object being plotted, here a line but not extras
from AxesOrigin, Prolog and Epilog. Hence the second of your results:

gr2=Plot[q[y], {y, -1, 1}, PlotStyle -> RGBColor[1, 0, 0],
AxesOrigin -> {0, 0}]

To complete the axes we can specify the plot range, interactively or by
programmiing:

Plot[q[y], {y, -1, 1}, PlotStyle -> RGBColor[1, 0, 0],PlotRange ->
{-.2,1.2},
AxesOrigin -> {0,0}]

Show[gr2,PlotRange -> {-.2,1.2}]

CompleteAxes[gr_]:=
Module[{xmin,xmax,ymin,ymax,ox,oy},
{{{xmin, xmax},{ymin,ymax}}, {ox, oy}}=
{PlotRange,AxesOrigin}/.AbsoluteOptions[gr];
Show[gr,
PlotRange ->
{{Min[xmin,ox],Max[xmax,ox]},
{Min[ymin,oy],Max[ymax,oy]}}
]
]

CompleteAxes[gr2],

You  might like to enlarges th plot range a little, say by 5%.

"aey" <york at orca.akctr.noaa.gov> wrote in message
news:83klp2\$1f8 at smc.vnet.net...
> Here are two step functions:
>
> p[x_] := If[.3 < x < 2, -3, .2]
> q[y_] := If[0 < y < 1, 1, .2]
>
> If I try to plot these function with a {0,0} origin specified, I get (what
> seem to me) inconsistent results:
>
> Plot[p[x], {x, -1, 1}, PlotStyle -> RGBColor[1, 0, 0],
> AxesOrigin -> {0, 0}]
>
> Plot[q[y], {y, -1, 1}, PlotStyle -> RGBColor[1, 0, 0],
> AxesOrigin -> {0, 0}]
>
> The first behaves as I thought it should. The axes cross at {0,0}. The
> second does not-- the y-axis is not completed.  This also occurs if the
> PlotStyle->RGBColor is not included in the Plot call. Is there a way to
get
> the axes to cross in the second case?
>
>
>
>

```

• Prev by Date: Re: Help: boundary value problem
• Next by Date: Re: Partial evaluation
• Previous by thread: Plotting a step function with the origin indicated
• Next by thread: Re: Plotting a step function with the origin indicated