Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

everyone!

I have got a little problem trying to draw in LaTeX.

Let me try to explain: I have a xyz-axis, as you can see on the figure below.

enter image description here

Plotting any 2-D data point graph in the xy-axis:

\begin{filecontents}{data.dat}
0 0
1 1
2 4
\end{filecontents}

\begin{document}

\begin{tikzpicture}[scale=1]

\draw[thick,->,black] (0,0,0) -- (2,0,0) node[anchor=west]{$x$};
\draw[thick,->] (0,0,0) -- (0,4.5,0) node[anchor=east]{$y$};
\draw[thick,->] (0,0,0) -- (0,0,1) node[anchor=east]{$z$};

\draw[smooth] plot file {data.dat};

\end{tikzpicture}

Resulting:

enter image description here

The problem is: I cannot plot a similar graph just in the zy-axis.

Any idea how to do it?

Thanks a lot!

share|improve this question

1 Answer 1

up vote 1 down vote accepted

This solution uses tikzlibrary 3d which makes it easier to draw 2d datum with 3d coordinates.

enter image description here

Code:

\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usepackage{filecontents}
\usetikzlibrary{3d}

\begin{document}

\begin{filecontents}{data.dat}
0 0 
1 1 
2 4 
\end{filecontents}

\begin{tikzpicture}
\draw[thick,->,black] (0,0,0) -- (2,0,0) node[anchor=west]{$x$};
\draw[thick,->] (0,0,0) -- (0,4.5,0) node[anchor=east]{$y$};
\draw[thick,->] (0,0,0) -- (0,0,2) node[anchor=east]{$z$};
\begin{scope}[canvas is xy plane at z=0]
      \draw [smooth] plot file {data.dat};
\end{scope}
\begin{scope}[canvas is xz plane at y=0]
      \draw [smooth] plot file {data.dat};
\end{scope}
\begin{scope}[canvas is yz plane at x=0]
      \draw [smooth] plot file {data.dat};
\end{scope}
\end{tikzpicture}
\end{document}
share|improve this answer
    
Perfect, @Jesse ! It was exactly what I needed! Thank you very much! –  user44331 Jan 18 at 20:27

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.