How to make 3D drawing in tikz

tikz-3dplottikz-pgf

Is there a way to make tikz draw in 3D, I am trying to draw vectors and axis in $ \mathbb{R}^3 $ (in the space), maybe not one that advanced since I am new at using latex.

this is a try for the axis:

\begin{tikzpicture}

  \draw [-latex](0,0)--(8,4);
  \draw [-latex](0,0)--(-4,-2);
  \draw (9,4.5) node {X};
  \draw [-latex](0,0)--(0,7);
  \draw (0,7.5) node {Y};
  \draw [-latex](0,0)--(8,-4);
  \draw (9,-4.5) node {Z};
\end{tikzpicture}

but it is really inconvenient to draw vectors in there since its 2D, I have to calculate with perspective.

the specific problem i try to solve is to draw the position vector of a line, the line and (if it is possible) a plane that contains the line and is perpendicular to the vector, but the first two are my main objectives.

Best Answer

It is not easy to understand what you are asking. Here is one way to use "3D" (coordinates given by three numbers).

Original code:

3D Axis

New code:

\documentclass[tikz, border=1cm]{standalone}
\begin{document}
\begin{tikzpicture}[x={(0.8cm,0.4cm)}, y={(0cm,0.7cm)}, z={(0.8cm,-0.4cm)}]
\draw[-latex] (0,0,0) -- (10,0,0);
\draw (11,0,0) node{X};
\draw[-latex] (0,0,0) -- (-5,0,0);
\draw[-latex] (0,0,0) -- (0,10,0);
\draw (0,11,0) node{Y};
\draw[-latex] (0,0,0) -- (0,0,10);
\draw (0,0,11) node{Z};
\end{tikzpicture}
\end{document}

Same 3D axis

x={(0.8cm,0.4cm)}, y={(0cm,0.7cm)}, z={(0.8cm,-0.4cm)} is only needed because of the non-standard orientation of the axis.