# Flipping axes direction in Graphics3D

Version I

Let's say I have a simple code like shown below:

data = Table[{i, i^2, i^3}, {i, -1, +1, 0.01}];
Graphics3D[{Red, Thick, Line@data}, Axes -> True, ViewPoint -> {-2, 2, 1}, ViewVertical -> {0, 2, 0}]


and here is the output: Is there a more-less elegant way to reverse the direction of one of the axes? I.e. to make so that values on one of the axes run from higher values to lower. Please note that I am not talking about some sort of rotation. I am aiming to flip the axis without changing the active view.

In a 2d ListPlotcase it is as easy as utilizing ScalingFunctions->{"Reverse", None}. Sadly ScalingFunctions do not work in this case.

Version II

I provide another example concerning the question here. So, a data to be plotted can be found by the link. And here is the code I used to plot it:

data = Import["data.hdf", {"Datasets", "Dataset1"}];
exp = Graphics3D[{Line /@ data},
BoxRatios -> {1, 1, 1/2}, PlotRange -> {{0, 7.5}, All, All},
Axes -> True, AxesLabel -> {"x", "y", "z"},
ImageSize -> 600,
ViewPoint -> {1.4, -2.6, 0.5}, ViewVertical -> {0.3, -0.5, 1.6}]


As a result I get following output: In this particular cases I want to flip the x axis, so I apply the two step transformations suggested in answer:

exp /. Graphics3D[a_, o__] :> Graphics3D[
a,
Ticks -> {ChartingScaledTicks["Reverse"], Automatic, Automatic},
o]


This is what I get as a preliminary output of this step: Then I continue with step 2:

exp /. Graphics3D[a_, o__] :> Graphics3D[
GeometricTransformation[a, ScalingTransform[{-1, 1, 1}]],
Ticks -> {ChartingScaledTicks["Reverse"], Automatic, Automatic},
o]


And here is the final output: So, sadly suggested solutions fails in my case or perhaps (most probably) I am applying it in a wrong way.

You can use GeometricTransformation with a non-default Ticks specification. I will do it in 2 steps. First, reverse one of the ticks:

g /. Graphics3D[a_,o__] :> Graphics3D[
a,
Ticks -> {ChartingScaledTicks["Reverse"],Automatic,Automatic},
o
] Then, use GeometricTransformation to invert the corresponding graphics primitives:

g /. Graphics3D[a_,o__] :> Graphics3D[
GeometricTransformation[a, ScalingTransform[{1, 1, -1}]],
Ticks -> {ChartingScaledTicks["Reverse"],Automatic,Automatic},
o
] Comment

The OP commented that my code only works for symmetric axes, so here is an example with asymmetric axes using the same technique:

data = Table[{i,6i^2,i^3},{i,-1,+1,0.01}];
g = Graphics3D[
{Red,Thick,Line@data},
Axes->True,
ViewPoint->{-2,2,1},
ViewVertical->{0,2,0}
] And my answer applied to the middle coordinate:

g /. Graphics3D[a_,o__] :> Graphics3D[
GeometricTransformation[a,ScalingTransform[{1,-1,1}]],
Ticks->{Automatic,ChartingScaledTicks["Reverse"],Automatic},
o
] It looks like my answer works with asymmetric axes as well.

Comment 2

If the original graphic has an explicit PlotRange, then you need to include an appropriately transformed PlotRange. For the OP example, the following does this:

exp /. Graphics3D[a_,o___] :> Graphics3D[
GeometricTransformation[a,ScalingTransform[{-1,1,1}]],
Ticks->{ChartingScaledTicks["Reverse"],Automatic,Automatic},
PlotRange->{{0,-7.5},All,All},
o
] • Thanks for the answer! But it seem to be working only with symmetrical axes. So, in my case, the axis I am trying to make run in a reverse direction is a Y axis with values going from 0 to 6. This code doesn't really reverse it, instead it only multiplies all of the values by "-1". So new axis becomes negative. – Bulat Munavirov Nov 2 '17 at 7:46
• @BulatMunavirov I added an example with asymmetric axes, and I don't see the behavior you describe. Perhaps you can update your question with the graphic that has the issue you describe. – Carl Woll Nov 2 '17 at 18:34
• I have modified the question adding the original data and code I am dealing with. Please see modifications under "Version II" part. – Bulat Munavirov Nov 15 '17 at 13:37
• @BulatMunavirov See update – Carl Woll Nov 15 '17 at 17:13