# LaTex Plot Axis 3D

There are many packages in LaTeX to plot 3D, including tikz-3dplot, and other exotic packages.

The easiest one to use for plotting a simple 3D graph, with xyz axis and origin, is Pgfplots in my opinion.

The code to plot the diagram below is included for reference.

First, we need to add the following in the preamble of the LaTeX document:

\usepackage{pgfplots}
\pgfplotsset{compat=1.8}

Then, to draw the actual diagram, the following simple code will do:

\begin{figure}[htbp]
\begin{center}
\begin{tikzpicture}
\begin{axis}[
ticks=none,
view={60}{30},
axis lines=center,
width=10cm,height=10cm,
xmin=-10,xmax=10,ymin=-10,ymax=10,zmin=-10,zmax=10,
xlabel={$x$},ylabel={$y$},zlabel={$z$}
]

% plot dots for the points
\addplot3 [only marks] coordinates {(1,2,3) (4,5,6)};

% plot dashed lines to axes
\addplot3 [no marks,densely dashed] coordinates {(1,2,3) (4,5,6)};

% label points
\node [above] at (axis cs:1,2,3) {$A (1,2,3)$};
\node [above right] at (axis cs:4,5,6) {$B (4,5,6)$};
\node [below left] at (axis cs:0,0,0) {$O$};
\end{axis}
\end{tikzpicture}
\caption{default}
\label{default}
\end{center}
\end{figure}

## Author: mathtuition88

https://mathtuition88.com/

This site uses Akismet to reduce spam. Learn how your comment data is processed.