1

I'm kinda new in TikZ, so question may sound stupid. How can I rotate the whole coordinate system? This is what I have (simple 3D coordinate system):

\begin{tikzpicture}[x=1cm, y=1cm, z=-0.6cm]
    % Axes
    \begin{scope}[rotate=0]
    \draw [<->] (-3,0,0) -- (12,0,0) node [at end, right] {$z$};
    \draw [<->] (0,-4,0) -- (0,4,0) node [at end, left] {$y$};
    \draw [<->] (0,0,2) -- (0,0,-4) node [at end, left] {$x$};
    \end{scope}
\end{tikzpicture}

So, this is an output:

enter image description here

And, this is what I'm trying to represent (I'm talking only about coordinate system and how it rotated):

enter image description here

Any help will be appreciated.

1
  • I think this post should be of great interest.
    – SebGlav
    Feb 27, 2021 at 15:06

1 Answer 1

3

Using this solution from Tom Bombadil, you can adjust each axis to give it the angle and aspect you want.

\documentclass[tikz,border=3.141592mm]{standalone}

\begin{document}

    \newcommand{\xangle}{30}
    \newcommand{\yangle}{90}
    \newcommand{\zangle}{-10}
    
    \newcommand{\xlength}{1}
    \newcommand{\ylength}{0.5}
    \newcommand{\zlength}{1}
    
    \pgfmathsetmacro{\xx}{\xlength*cos(\xangle)}
    \pgfmathsetmacro{\xy}{\xlength*sin(\xangle)}
    \pgfmathsetmacro{\yx}{\ylength*cos(\yangle)}
    \pgfmathsetmacro{\yy}{\ylength*sin(\yangle)}
    \pgfmathsetmacro{\zx}{\zlength*cos(\zangle)}
    \pgfmathsetmacro{\zy}{\zlength*sin(\zangle)}
    
    \begin{tikzpicture}[
        x={(\xx cm,\xy cm)},
        y={(\yx cm,\yy cm)},
        z={(\zx cm,\zy cm)}
        ]
        % Axes
        \begin{scope}
        \draw [<->] (-2,0,0) -- (2,0,0) node [at end, right] {$x$};
        \draw [<->] (0,-4,0) -- (0,4,0) node [at end, left] {$y$};
        \draw [<->] (0,0,-2) -- (0,0,6) node [at end, above] {$z$};
        \end{scope}
    \end{tikzpicture}

\end{document}

enter image description here

edit: I deleted two lines in the code that were redundant (copy fail).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .