Graphics, Figures & TablesLines in 3D Space

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
DanLamb
Posts: 1
Joined: Tue Feb 12, 2013 5:22 am

Lines in 3D Space

Post by DanLamb »

I expected the following to render two lines: (y=1,z=3) and (y=2,z=5)

Code: Select all

\begin{tikzpicture}
  \begin{axis}[
    3d box=complete,
    grid=major,
    xlabel=$x$,
    ylabel=$y$,
    zlabel=$z$,
    samples=5
  ]
    \addplot3[color=red,domain=0:200,y domain=1:1,samples=201,samples y=1,variable y=\y] {3};
    \addplot3[color=green,domain=0:200,y domain=2:2,samples=201,samples y=1,variable y=\y] {5};
  \end{axis}
\end{tikzpicture}
Yet y is always zero. Also, how do I render z=y. I tried using {\y}, but that errors.

I basically want to render lines in 3D space and it doesn't seem to work. I've also done several dozen Internet searches and read through the documentation before posting this.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

Post Reply