6

In astronomy, right ascension is usually plotted with positive values that increase from right to left. I have seen discussions of successful and unsuccessful attempts to reverse the order of an axis in Mathematica, but I haven't seen anything that applies specifically to the ParametricPlot[] function, and perhaps I am not good enough at Mathematica to see how the other solutions using ScalingFunctions or Transpose might be applied here. I tried a few to no avail.

Plot 2 uses the default frame ticks, showing reversal of plotting order by reversing the signs of the $x$-coordinates of the plot objects. In the Ticks option, their specs seem to be ordered {{left, right}, {bottom, top}} with respect to the frame sides. I believe that replacing one of these terms, say left, with something like {-1, 1} would replace -1 with 1 on the left side. But when I attempted to change the names of the ticks on the $x$-axis in plot 2 to positive numbers, the ticks and their names both disappeared, as in plot 3. I could replace the missing ticks with a cumbersome Epilog list, but I would prefer something more elegant. It strikes me as odd that the mathematicians who created Mathematica would arbitrarily limit their orientation, so there must be a native way of reversing order, no? The following three scripts produce these three plots in a row:

attempts to plot with reversed axes

Clear["Global`*"]

spiral[a_, t_, x_, y_] := {a*t*Cos[t] + x, a*t*Sin[t] + y} // N;

fs = 8; (* font size *)
objects = 5;
fl = {X, Rotate[Y, -Pi/2]}; (* frame label *)

unreversed = 
 ParametricPlot[
  spiral[.002*#^(5/3), t, #, #] & /@ Range[objects], {t, 0, 10*Pi},
   PlotRange -> {{0, objects + 1}, {0, objects + 1}}, 
   PlotLabel -> Style["1. x axis not reversed", FontSize -> fs], 
   Frame -> True, FrameLabel -> fl, GridLines -> Automatic];

reversed1 = 
  ParametricPlot[
   spiral[.002*#^(5/3), t, -#, #] & /@ Range[objects], {t, 0, 
    10*Pi}, PlotRange -> {{-objects - 1, 0}, {0, objects + 1}}, 
   PlotLabel -> Style["2. x axis reversed", FontSize -> fs], 
   Frame -> True, FrameLabel -> fl, GridLines -> Automatic];

ticks = {{Automatic, None}, {{-#, #}, None}} & /@ 
   Reverse[Range[objects]];

reversed2 = 
  ParametricPlot[
   spiral[.002*#^(5/3), t, -#, #] & /@ Range[objects], {t, 0, 
    10*Pi}, PlotRange -> {{-objects - 1, 0}, {0, objects + 1}}, 
   PlotLabel -> 
    Style["3. x axis reversed\nticks lost", FontSize -> fs], 
   Frame -> True, FrameLabel -> fl, GridLines -> Automatic, 
   FrameTicks -> ticks (* causes ticks to disappear *)];

GraphicsRow[{unreversed, reversed1, reversed2}]
Mr.Wizard
  • 271,378
  • 34
  • 587
  • 1,371
Gary
  • 569
  • 3
  • 13
  • I notice in your examples that you are not reversing the spirals themselves. Is this deliberate? – Mr.Wizard Oct 18 '12 at 12:20
  • @Mr.Wizard The orientation of the spirals was not a concern, but it could become meaningful in the future. – Gary Oct 18 '12 at 16:06

1 Answers1

7

I cannot recall a built-in method to reverse an axis, at least for ParametricPlot, but maybe the right FrameTicks syntax will help:

ticks = {{{-6, 6}, {-5, 5}, {-4, 4}, {-3, 3}, {-2, 2}, {-1, 1}, {0, 0}}, {{0, 
   0}, {1, 1}, {2, 2}, {3, 3}, {4, 4}, {5, 5}, {6, 6}}, {}, {}};

ParametricPlot[
 spiral[.002*#^(5/3), t, -#, #] & /@ Range[objects], {t, 0, 10*\[Pi]},
  PlotRange -> {{-objects - 1, 0}, {0, objects + 1}}, 
 PlotLabel -> Style["3. x axis reversed\nticks lost", FontSize -> fs],
  Frame -> True, FrameLabel -> fl, GridLines -> Automatic, 
 FrameTicks -> ticks]

Mathematica graphics

It's possible that this version-8 function may work with ParametricPlot, though I can't test that, and ParametricPlot doesn't appear to be supported: ScalingFunctions

Update

In Mathematica 10 ScalingFunctions does work with ParametricPlot, though it is undocumented.

spiral[a_, t_, x_, y_] := {a*t*Cos[t] + x, a*t*Sin[t] + y};

ParametricPlot[
 spiral[.002*#^(5/3), t, #, #] & /@ Range[5]
 , {t, 0, 10*Pi}
 , GridLines -> Automatic
 , ScalingFunctions -> #
 , PlotLabel -> {#}
] & /@ Tuples[{Identity, "Reverse"}, 2]

enter image description here

Mr.Wizard
  • 271,378
  • 34
  • 587
  • 1,371
  • This is my accepted answer. I see that I had the syntax all wrong. Why is it that the following doesn't work? It produces an output that looks equivalent to the above "ticks". xTicks = {-#, #} & /@ Reverse[Range[6]]

    yTicks = {#, #} & /@ Range[6]

    ticks = {{xTicks, yTicks}, {}, {}}

    – Gary Oct 18 '12 at 16:37
  • Wizard Never mind, I see it. It should be ticks = {xTicks, yTicks, {}, {}}. Thanks much. – Gary Oct 18 '12 at 16:52