Skip to main content
edited tags
Link
Mr.Wizard
  • 273.1k
  • 34
  • 595
  • 1.4k
added 54 characters in body; edited title
Source Link

How do I reverse the axis usingin ParametricPlot?

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 MathematicaMathematica, but I haven't seen anything that applies specifically to the ParametricPlotParametricPlot[] function, and perhaps I am not good enough at MMAMathematica to see how the other solutions using ScalingFunctionsScalingFunctions or TransposeTranspose 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$x$-coordinates of the plot objects. In the TicksTicks option, their specs seem to be ordered {{left, right}, {bottom, top}}{{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}{-1, 1} would replace -1-1 with 11 on the left side. But when I attempted to change the names of the ticks on the x axis$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 EpilogEpilog list, but I would prefer something more elegant. It strikes me as odd that the mathematicians who created MathematicaMathematica would arbitrarily limit their orientation, so there must be a native way of reversing order. No, no? The following three scripts produce these three plots in a row:

Mathematica graphicsattempts 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*font size *)
objects=5;objects = 5;
fl=fl = {X, Rotate[Y, -Pi/2]}; (*frame* label*frame label *)

unreversed = 
 ParametricPlot[
  spiral[.002*#^(5/3), t, #, #] & /@ Range[objects], {t, 0, 10*\[Pi]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]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]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* causes ticks to disappear*disappear *)];

GraphicsRow[{unreversed, reversed1, reversed2}]

How reverse axis using ParametricPlot?

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 MMA 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:

Mathematica graphics

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}]

How do I reverse the axis in ParametricPlot?

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}]
Tweeted twitter.com/#!/StackMma/status/258902371244056576
added 54 characters in body
Source Link
Mr.Wizard
  • 273.1k
  • 34
  • 595
  • 1.4k

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:


 Clear["Global`*"]



spiral[a_, t_, x_, y_] := { atCos[t] + x, atSin[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*π},
 

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*π},
 

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π},
 

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}]
Mathematica graphics

(* END *)

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}]

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 three plots in a row:


 Clear["Global`*"]



spiral[a_, t_, x_, y_] := { atCos[t] + x, atSin[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*π},
 

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*π},
 

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π},
 

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}]


(* END *)

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:

Mathematica graphics

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}]
Source Link
Gary
  • 569
  • 3
  • 13
Loading