# Oblique projection in 3d pgfplots

How can I make pgfplots to show the coordinate system from a view like in the following picture. The graph paper doesn't matter, but as you can see the x_1 axis should be relative to the graph paper trough the diagonals of the squares. Say if two squares are one unit for the x_2 and x_3 axis, one unit for the x_3 axis should be just a diagonal of one square.

Manipulating the view options didn't give the desired results:

\documentclass{standalone}

\usepackage{pgfplots}

\begin{document}
\begin{tikzpicture}
\begin{axis}[xmax=2.5,ymax=2.5,zmax=1.45,xlabel=$x_1$,ylabel=$x_2$,zlabel=$x_3$,axis lines=center,view={135}{45}]
opacity=0.3,
surf,
samples=50,
domain=-2:2,y domain=-2:2]
{exp(-(x^2+y^2))};
\end{axis}
\end{tikzpicture}
\end{document}


Output:

Here the x_2 axis is not to the right.

• I'm almost sure that you can't do oblique projection. You shouldn't do it anyways for proper data visualizations. Commented Jun 28, 2015 at 11:55
• Thanks for the keyword "oblique projection". This leads me to the solution below. Commented Jun 28, 2015 at 12:30

Percusse's comment provided the key word "oblique projection". Some googeling lead me to the following solution:

\documentclass{standalone}

\usepackage{pgfplots}

\begin{document}
\begin{tikzpicture}
\begin{axis}[
x={(-0.3535cm,-0.3535cm)},
y={(1cm,0.0cm)},
z={(0cm,1cm)},
xmax=2.5,ymax=2.5,zmax=1.45,
xlabel=$x_1$,ylabel=$x_2$,zlabel=$x_3$,
axis lines=center]
opacity=0.3,
surf,
samples=50,
domain=-2:2,y domain=-2:2]
{exp(-(x^2+y^2))};
\end{axis}
\end{tikzpicture}
\end{document}


• Ah you want to change the orientation... My bad. I misunderstood. Commented Jun 28, 2015 at 12:52
• But this is an oblique, isn't it? Commented Jun 28, 2015 at 13:19

You can format axis, and show a coordinate of your choice:

\documentclass{article}

\usepackage{pgfplots}

\pagestyle{empty}

\begin{document}
\begin{tikzpicture}[font=\tiny]
\begin{axis}[
axis x line = middle,
axis y line = middle,
axis z line = middle,
view={150}{35},
domain =-5:5,
y domain =-5:5,
restrict z to domain =0:20,
xmax =5,
xmin =-5,
ymax =5,
ymin =-5,
zmax = 20,
zmin = 0,
xtick={-4,...,4},
ytick={-4,...,4},
ztick={0,4,...,20}
]
\draw (4,4,16) node[above left] {\normalsize $A$};
\draw[dashed] (4,4,16)--(0,0,16);
\draw[dashed] (4,4,16)--(4,4,0);
\draw[dashed] (4,0,0)--(4,4,0)--(0,4,0);
\filldraw (4,4,16)  circle(1pt);
\filldraw (4,4,0)  circle(1pt);
\filldraw (4,0,0)  circle(1pt);
\filldraw (0,4,0)  circle(1pt);
\filldraw (0,0,16)  circle(1pt);
\end{axis}
\end{tikzpicture}
\end{document}


and view={150}{35} command works fine, first part changes XOY plane, send rotates Z axis.

https://youtu.be/00S9l7pGkQY in this video I show some manipulations with plots. Language of video is georgian, but everything is clearly shown.

• Thanks, but if I compile your example the x_2 axis doesn't point to the right. Commented Jun 28, 2015 at 12:35
• it is done by xlable={$x$}, in video is shown how lables are added Commented Jun 28, 2015 at 12:37
• This just add's the label. The orientation of the axis is wrong. Compare the picture in my question and in my solution. Commented Jun 28, 2015 at 17:11
• I already wrote in answer orientation is set by view={}{} command, by changing numbers you will chage orientation of axis, and choose which you will like. Commented Jun 28, 2015 at 17:48