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

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Post Reply