Re: Reverse Axes in Plot
- To: mathgroup at smc.vnet.net
- Subject: [mg23697] Re: [mg23659] Reverse Axes in Plot
- From: BobHanlon at aol.com
- Date: Mon, 29 May 2000 12:24:26 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
In a message dated 5/28/2000 11:25:24 PM, chapmand at accesscable.net writes:
>I would like to plot a simple 2D plot with the y-axis increasing
>DOWNwards instead of UPwards. Does anyone know how to do this? I have
>looked high and low for the answer!
>
Using Version 4,
reversedPlot[expr_,
{var_Symbol, varMin_?NumericQ, varMax_?NumericQ},
{REVx_?(Element[#, Booleans] &),
REVy_?(Element[#, Booleans] &)},
opts___] :=
Module[{plt =
Plot[expr, {var, varMin, varMax}, opts, DisplayFunction -> Identity]},
Show[{
plt /.
{x_?NumericQ, y_?NumericQ} :> {If[REVx, -x, x], If[REVy, -y, y]}},
Ticks -> {
If[REVx, (Ticks /. AbsoluteOptions[plt, Ticks])[[1]] /.
{x_, label_, len_, style_} :> {-x, label, len, style},
Automatic],
If[REVy, (Ticks /. AbsoluteOptions[plt, Ticks])[[2]] /.
{y_, label_, len_, style_} :> {-y, label, len, style},
Automatic]
},
DisplayFunction -> $DisplayFunction]]
f[x_] := 3x - 7
xmin = -2; xmax = 5;
Basic Plot
Plot[f[x], {x, xmin, xmax}, PlotStyle -> RGBColor[1, 0, 0]];
reversedPlot with neither axis reversed, i.e., same as basic Plot
reversedPlot[f[x], {x, xmin, xmax}, {False, False},
PlotStyle -> RGBColor[1, 0, 0]];
reversedPlot with y axis reversed
reversedPlot[f[x], {x, xmin, xmax}, {False, True},
PlotStyle -> RGBColor[1, 0, 0]];
reversedPlot with x axis reversed
reversedPlot[f[x], {x, xmin, xmax}, {True, False},
PlotStyle -> RGBColor[1, 0, 0]];
reversedPlot with both x and y axes reversed
reversedPlot[f[x], {x, xmin, xmax}, {True, True},
PlotStyle -> RGBColor[1, 0, 0]];
Bob
BobHanlon at aol.com