Re: Plot backwards ==> SOLVED, THANK YOU.
- To: mathgroup at smc.vnet.net
- Subject: [mg40799] Re: Plot backwards ==> SOLVED, THANK YOU.
- From: "Gustavo Seabra" <seabra at ksu.edu>
- Date: Thu, 17 Apr 2003 23:17:37 -0400 (EDT)
- Organization: Kansas State University
- References: <b7irc6$juh$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Hi all, Thanks everyonr that tried to help. As what I wanted was to make the plot in reverse order, the solution wasn't in the Ticks option - this only changes the label, not the actual order that data is plotted. The solutions tat worked as I wanted were the ones sent by Allan Hayes and Mihajlo Vanevic, and involve creating an user-defined function to plot the points in reverse order. These solutions are sumarized here. Thanks everyone, Gustavo Seabra. ===== Solutions that worked ======================================= I hope Mathematica 4.0 *for students* supports AbsoluteOptions etc.. If it is so, then try In[]:= Clear[invPlot]; invPlot[fun_, {x_, a_, b_}, opts___] := Module[ {absopt, plt, myTicks}, plt = Plot[Evaluate[fun /. x -> -x], {x, -a, -b}, opts, DisplayFunction -> Identity]; absopt = AbsoluteOptions[plt]; myTicks = Ticks /. absopt; myTicks = {First[myTicks] /. List[m_, n_?(NumberQ[#] && Negative[#] &), p_, q_] :> List[m, If[FractionalPart[n] == 0., -Round[n], -n], p, q], Last[myTicks] /. List[m_, n_?(NumberQ[#] &), p_, q_] :> List[m, If[FractionalPart[n] == 0., Round[n], n], p, q]}; Show[plt /. Rule[Ticks, ls_] -> Rule[Ticks, myTicks], DisplayFunction -> $DisplayFunction] ]; Test: In[]:= invPlot[{Sin[x], Cos[x], x/10}, {x, 0, 10}, PlotStyle -> {Hue[.3], Hue[.6], Hue[1.]}] Regards, Mihajlo Vanevic mvane at EUnet.yu 2003-04-16 ---------------------------------------------------------------------------- ------------ Gustavo, << Graphics`Graphics` To get the function LinearScale. ReverseGraphics[gr_] := Module[{a, b, rev, xrev, xticks}, {a, b} = PlotRange[gr][[1]]; rev[x_] = InterpolatingPolynomial[{{a, b}, {b, a}}, x]; xrev[{x_, y_}] = {rev[x], y}; xticks = xrev /@ LinearScale[a, b]; Show[gr /. { el:_Line | _Point | _Polygon :> Map[xrev, el, {-2}], tx_Text :> MapAt[xrev, tx, {2}]}, Ticks -> {xticks, Automatic}] ] Check gr = Plot[2*x, {x, 0, 1}, Epilog -> {{PointSize[0.1], Point[{0.2, 0.5}]}, Polygon[{{0, 1}, {0.3, 1.5}, {0.5, 1.2}}], Text["Text", {0.1, 1.5}]}] ReverseGraphics[gr] -- Allan --------------- Allan Hayes hay at haystack.demon.co.uk Voice: +44 (0)116 241 8747 Fax: +44 (0)870 164 0565 =========================================================== "Gustavo Seabra" <seabra at ksu.edu> escreveu na mensagem news:b7irc6$juh$1 at smc.vnet.net... > Hi, > > I am Using Mathematica 4.0 for Students. I'm trying to plot a function, > but I need the x axis to decrease to the right, instead of increasing, like: > > -|----|----|----|----| > 25 20 15 10 0 > > I've looked everywhere I could think of. Would anyone hava suggestions? > > Thanks, > Gustavo Seabra. > > >