# How to exchange axes in a 3D plot (from right- to left-handed coordinate system)

I have, as an example, a 3D plot showing some data:

data = {{100, 0, 0}, {0, 80, 0}, {0, 0, 60}}

ListPointPlot3D[data, PlotStyle -> {PointSize[0.04]}, BoxRatios -> {100, 80, 60},
Boxed -> True, Axes -> True, AxesLabel -> {"x", "y", "z"},
ViewProjection -> "Orthographic", AxesEdge -> {{-1, -1}, {-1, -1}, {-1, -1}},
PlotRange -> {{0, 100}, {0, 80}, {0, 60}}]


I want to exchange the $y$ and $z$ axes to switch to a left-handed coordinate system.

Manually, I can do:

datanew = {{100, 0, 0}, {0, 60, 0}, {0, 0, 80}};

ListPointPlot3D[datanew, PlotStyle -> {PointSize[Large]}, BoxRatios -> {100, 60, 80},
Boxed -> True, Axes -> True, AxesLabel -> {"x", "z", "y"},
ViewProjection -> "Orthographic", AxesEdge -> {{-1, -1}, {-1, -1}, {-1, -1}},
PlotRange -> {{0, 100}, {0, 60}, {0, 80}}]


Does a built-in solution exist to exchange two axes, whereby the $y$ and $z$ data are exchanged as well as the axes labels?

lpp3d = ListPointPlot3D[data, PlotStyle -> {PointSize[0.04]},
BoxRatios -> {100, 80, 60}, Boxed -> True, Axes -> True,
AxesLabel -> {"x", "y", "z"},
ViewProjection -> "Orthographic",
AxesEdge -> {{-1, -1}, {-1, -1}, {-1, -1}},
PlotRange -> {{0, 100}, {0, 80}, {0, 60}}]

newoptions= Flatten[{(# -> (# /. Options[lpp3d])[[{1,3,2}]])&/@
{BoxRatios, AxesLabel, BoxRatios, PlotRange},
FilterRules[Options[lpp3d], {Boxed, Axes, ViewProjection, AxesEdge}]}];

ListPointPlot3D[data[[All, {1,3,2}]], PlotStyle -> {PointSize[0.04]}, newoptions]


Alternatively,, post-process to change the graphics primitives and options:

f = #[[{1, 3, 2}]]&;
lpp3d /. { Point[x_] :> Point[f/@x],
Rule[o: Alternatives[BoxRatios, AxesLabel, BoxRatios, PlotRange], v_] :> Rule[o, f @ v]}


same picture

This could be a good place for some pattern matching. To switch the data around:

data = {{100, 0, 0}, {0, 80, 0}, {0, 0, 60}};
datanew = data[[#]] /. {x_, y_, z_} -> {x, z, y} & /@ Range[Length[data]]

{{100, 0, 0}, {0, 0, 80}, {0, 60, 0}}


The simplest way to accomplish this is to set ViewVertical appropriately:

data = {{100, 0, 0}, {0, 80, 0}, {0, 0, 60}};
ListPointPlot3D[data, AxesEdge -> {{-1, -1}, {-1, -1}, {-1, -1}},
AxesLabel -> {"x", "y", "z"}, BoxRatios -> {100, 80, 60},
PlotRange -> {{0, 100}, {0, 80}, {0, 60}},
PlotStyle -> PointSize[0.04], ViewProjection -> "Orthographic",
ViewVertical -> UnitVector[3, 2]]


This is a solution from Wolfram:

data = {{100, 0, 0}, {0, 80, 0}, {0, 0, 60}};

rhListPointPlot3D[data_, opts : OptionsPattern[ListPointPlot3D]] :=
Module[{newDat = data /. {x_?NumericQ, y_?NumericQ, z_?NumericQ} :> {x, z, y}},
ListPointPlot3D[newDat, opts]]

rhListPointPlot3D[data, PlotStyle -> {PointSize[Large]}, BoxRatios -> {100, 60, 80},
Boxed -> True, Axes -> True, AxesLabel -> {"x", "z", "y"},
ViewProjection -> "Orthographic", AxesEdge -> {{-1, -1}, {-1, -1}, {-1, -1}},
PlotRange -> {{0, 100}, {0, 60}, {0, 80}}]