MathGroup Archive 1999

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

Search the Archive

Re: help - how to invert the x or y axis..

  • To: mathgroup at smc.vnet.net
  • Subject: [mg17373] Re: help - how to invert the x or y axis..
  • From: colin at tri.org.au (Colin Rose)
  • Date: Thu, 6 May 1999 02:44:02 -0400
  • Organization: Theoretical Research Institute
  • References: <7gfrhg$6dt@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Jao Wei-Chun <jao at chara.gsu.edu> wrote:

> Does anyone know how to invert the x or y axis?
> I want the y-axis to increase downward, instead of upward.


I haven't heard of Mongo. Nevertheless, we can make our own funny Plot fn
in Mathematica. 
The basic idea is to generate a standard Plot, and then impose the replacement:

       {x_,y_} -> {x, GAP-y}

where GAP is some arbitrary value on the y-axis.
The tricky bit is getting the Tick marks right. Here we go ...

_____

 FunnyPlot[pp_Graphics, opts___Rule] := Module[{sol1, sol2, lis, GAP, qq, x, y},
   {sol1, sol2} = AbsoluteOptions[pp,Ticks][[2]];
   lis = Select[Flatten[Cases[sol2,
           {x1_,x2_,{x3_,x4_},{GrayLevel[0.],AbsoluteThickness[0.25]}}]],
         NumericQ];
   GAP = Max[lis]-Min[lis];      
   qq[x_]:=If[FractionalPart[x]===0., IntegerPart[x], x];   
   Show[pp/.{x_,y_} -> {x,GAP-y}, Evaluate[opts],
     AxesOrigin -> AbsoluteOptions[pp, AxesOrigin][[2]] /. {x_, y_} -> {x,
GAP-y},
     Ticks -> MapAll[qq,{sol1, Map[{GAP-First[#], Sequence@@Rest[#]}&, sol2]}]]]


Examples
________

    pp = Plot[x^3, {x, -3, 2}, PlotRange -> All];

    FunnyPlot[pp];


    pp = Plot[x^3, {x, 1, 2}, PlotRange -> All];

    FunnyPlot[pp];


    pp = Plot[Sin[x], {x, -\[Pi], \[Pi]}];

    FunnyPlot[pp, PlotLabel -> "Peekaboo"];


It seems to work rather nicely, even though it is a bit of a hack :)

Cheers

Colin

-- 
Colin Rose 
tr(I)    -  Theoretical Research Institute
__________________________________________
colin at tri.org.au    http://www.tri.org.au/


  • Prev by Date: Re: Horner's method on subexpressions
  • Next by Date: Re: How can I plot a file of <x, y, z> points?
  • Previous by thread: Re: help - how to invert the x or y axis..
  • Next by thread: The behaviour of DisplayTogether