Categories

# Really easy 3D graphics in LaTeX

Note: The word "easy" is relative to the other solutions I found for doing 3D graphics in LaTeX.

The following template is adapted from the annotated 3d box example.

% Template for drawing with tikz 3D package \documentclass[]{article} \usepackage{tikz} \usetikzlibrary{3d}   \begin{document}   % Draw a 3D coordinate system   \begin{center} \begin{tikzpicture}[x = {(1cm,0cm)}, y = {(0.4cm,0.6cm)}, z = {(0cm,1cm)}, scale = 1, color = {lightgray}]   \begin{scope}[canvas is xy plane at z=0] % x-axis \draw[blue,->] (0,0) -- (5,0) node (x-axis) [right] {$x$}; % y-axis \draw[red,->] (0,0) -- (0,5) node (y-axis) [above] {$y$}; \end{scope}   \begin{scope}[canvas is yz plane at x=0] % z-axis \draw[green,->] (0,0) -- (0,5) node (z-axis) [above] {$z$}; \end{scope}   \end{tikzpicture} \end{center} \end{document}

The code is almost self-explanatory, but here is the explanation. You can draw in either the xy plane (for z=something), the xz plane (for y=something) or the yz plane (for x=something). If all you want to do is draw in these planes, then the above template is a good place to start. It draws a coordinate system.

The x, y and z values in the following snippet, defines the directions of the x, y and z axis, when projected onto your computer screen. Play around with the values and see what happens if you don't get it right away:

\begin{tikzpicture}[x = {(1cm,0cm)}, y = {(0.4cm,0.6cm)}, z = {(0cm,1cm)},

You pick the plane you want to draw in. To draw in the yz plane where it intersects the x-axis at x=0, do the following:

\begin{scope}[canvas is yz plane at x=0]

## One reply on “Really easy 3D graphics in LaTeX”

[…] here: Really easy 3D graphics in LaTeX | skipperkongen.dk Categories: 3d Graphics, Uncategorized Tags: amazon, archives, archives-select, cloud-databases, […]

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