# How to rotate tikz graphics in 3d

Hello I would like to rotate the following tikz image about the y axis so that the lines connecting the crests (top) of the wave is a bit more vertical. So essentially how do you rotate the following 3d tikz image about the y axis about 10 or so degrees.

begin{tikzpicture}[xscale=1]
\draw (0,0,0) sin (1,1,0) cos (2,0,0) sin (3,-1,0) cos (4,0,0) sin (5,1,0) cos
(6,0,0) sin (7,-1,0);
\draw (0,0,4) sin (1,1,4) cos (2,0,4) sin (3,-1,4) cos (4,0,4) sin (5,1,4) cos
(6,0,4) sin (7,-1,4);
\draw (0,0,-2) sin (1,1,-2) cos (2,0,-2) sin (3,-1,-2) cos (4,0,-2) sin
(5,1,-2) cos (6,0,-2) sin (7,-1,-2);
\draw (0,0,2) sin (1,1,2) cos (2,0,2) sin (3,-1,2) cos (4,0,2) sin (5,1,2) cos
(6,0,2) sin (7,-1,2);
\draw (1,1,-2) -- (1,1,4);
\draw (5,1,-2) -- (5,1,4);
\end{tikzpicture}


## 2 Answers

Something like this? I redefined the z axis vector to z={(0.1,0.3)}. Change these numbers as you please.

\documentclass[tikz,border=1cm]{standalone}
\begin{document}
\begin{tikzpicture}[z={(0.1,0.3)},xscale=1]
\draw (0,0,0) sin (1,1,0) cos (2,0,0) sin (3,-1,0) cos (4,0,0) sin (5,1,0) cos
(6,0,0) sin (7,-1,0);
\draw (0,0,4) sin (1,1,4) cos (2,0,4) sin (3,-1,4) cos (4,0,4) sin (5,1,4) cos
(6,0,4) sin (7,-1,4);
\draw (0,0,-2) sin (1,1,-2) cos (2,0,-2) sin (3,-1,-2) cos (4,0,-2) sin
(5,1,-2) cos (6,0,-2) sin (7,-1,-2);
\draw (0,0,2) sin (1,1,2) cos (2,0,2) sin (3,-1,2) cos (4,0,2) sin (5,1,2) cos
(6,0,2) sin (7,-1,2);
\draw (1,1,-2) -- (1,1,4);
\draw (5,1,-2) -- (5,1,4);
\end{tikzpicture}
\end{document}

• Oh wow I didn't know it was that easy Jul 19, 2018 at 14:01

First of all, you can change the appearance of your 3-dimensional plot by defining the x, y and z vectors:

\tikzstyle{isometric}=[x={(0.710cm,-0.410cm)},y={(0cm,0.820cm)},z={(-0.710cm,-0.410cm)}]
\tikzstyle{manual}   =[x={(1cm,0cm)},y={(0cm,1cm)},z={(0.4cm,0.7cm)}]
\tikzstyle{dimetric} =[x={(0.935cm,-0.118cm)},y={(0cm,0.943cm)},z={(-0.354cm,-0.312cm)}]


and using those styles for your tikzpicture, just as you used xscale:

\begin{tikzpicture}[isometric]


Otherwise, you could take a look at the tikz-3dplot package, which allows you to do the same using rotations (and many more useful things, but it might be overkill for you):

\usepackage{tikz-3dplot}
\tdplotsetmaincoords{10}{0}

\begin{tikzpicture}[xscale=1,tdplot_main_coords ]