4

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!

1

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}
1
  • Perfect, @Jesse ! It was exactly what I needed! Thank you very much!
    – Agaeme
    Jan 18 '14 at 20:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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