MathGroup Archive 1998

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

Search the Archive

Reversing the axis of a plot

  • To: mathgroup at smc.vnet.net
  • Subject: [mg15044] Reversing the axis of a plot
  • From: "John C. Erb, Ph.D." <JOHN_C_ERB at prodigy.net>
  • Date: Wed, 9 Dec 1998 04:12:27 -0500
  • Sender: owner-wri-mathgroup at wolfram.com

Occasionally, I have would like to make a plot where one of the axes is
reversed; Mathematica does not seem to have this capability built in.

Wolfram support shows how to reverse the order of ticks in a plot (see
www.wolfram.com/support/Graphics/Axes/Ticks/Reverse.html); however it
does not reverse the plot,just the ticks on the axis.

The best workaround I've come up is given in the following example,
which makes use of reversing the ticks.

I want to reverse the x-axis of the
plot of 3x^2+5x+2.

To get a normal plot I could
use: Plot[3x^2+5x+2,{x,0,5}];

To reverse the plot for the x-axis,
I would do the following.
---------------------------------------------------------
Needs["ExtendGraphics`Ticks`"];

tickreverse[start_,finish_]:=
    TickFunction[start,finish,TextFunction->Reverse];

this=Table[{x,3x^2+5x+2},{x,0,5,0.25}]; {x,y}=Transpose[this];
that=Transpose[{Reverse[x],y}];
ListPlot[that,Ticks->{tickreverse,Automatic},PlotJoined->True];
---------------------------------------------------------- NOTE: For
some reason, the above needs to be in 3 separate cells to function
properly. Does anyone have a more eloquent solution or any comments?

John C. Erb

email: John_C_Erb at prodigy.net


  • Prev by Date: Width of a Text[] object
  • Next by Date: Re: Variables names
  • Previous by thread: Width of a Text[] object
  • Next by thread: Re: Reversing the axis of a plot