11

I'm trying to represent 3 points in a 3D Cartesian plane. I can do the Cartesian plane but I can not make the grid and color the parts of the plan in yellow, orange and blue. Can you help me?

\documentclass{standalone}
\usepackage{tikz}
\begin{document}

\begin{tikzpicture}[x=1pt, y=1pt, z=-0.5pt]  % Agh
% Let's draw some 3D axes
\coordinate (x) at (100,0,0);
\coordinate (y) at (0,100,0);
\coordinate (z) at (0,0,100);
\foreach \axis in {x,y,z}
\draw[-latex] (0,0,0) -- (\axis);

\end{tikzpicture}

\end{document}

enter image description here

1 Answer 1

10

This should get you started

\documentclass[]{article}
\usepackage{tikz}
\usetikzlibrary{3d}
\usetikzlibrary{calc}

\begin{document}

 \begin{tikzpicture} [x={(-0.6cm,-0.4cm)}, y={(1cm,0cm)}, z={(0cm,1cm)}, scale=1]
   \begin{scope}[canvas is zy plane at x=0]
     \fill[blue, opacity = 0.2] (0, 0) rectangle (6, 6);
     \draw[gray!40] (0, 0) grid (6, 6);
   \end{scope}

   \begin{scope}[canvas is zx plane at y=0]
     \fill[orange, opacity = 0.2] (0, 0) rectangle (6, 8);
     \draw[gray!40] (0, 0) grid (6, 8);
     \draw[black, -latex] (0, 0) -- (6.5, 0) node[left] {$z$};

     \draw[gray, -latex] (0, 0) -- (-3.5, 0);
     \foreach \z in {1,...,6} \draw[] (\z, -0.1) -- (\z, 0.1) node[left]{\z};
     \foreach \z in {-3,...,-1} \draw[gray] (\z, -0.1) -- (\z, 0.1) node[left]{\z};

   \end{scope}

   \begin{scope}[canvas is yx plane at z=0]
     \fill[yellow, opacity = 0.2] (0, 0) rectangle (6, 8);
     \draw[gray!40] (0, 0) grid (6, 8);

     \draw[black, -latex] (0, 0) -- (6.5, 0) node[above] {$y$};
     \draw[black, -latex] (0, 0) -- (0, 8.5) node[above] {$x$};

     \draw[gray, -latex] (0, 0) -- (0, -8.5);
     \foreach \x in {0,...,8} \draw[] (-0.1, \x) -- (0.1, \x) node[right]{\x};
     \foreach \x in {-8,...,-1} \draw[gray] (-0.1, \x) -- (0.1, \x) node[right]{\x};

     \draw[gray, -latex] (0, 0) -- (-4.5, 0);
     \foreach \y in {1,...,6} \draw[] (\y, -0.1) -- (\y, 0.1) node[below]{\y};
     \foreach \y in {-4,...,-1} \draw[gray] (\y, -0.1) -- (\y, 0.1) node[below]{-\y};
   \end{scope}

   \fill[black] (2, 4, 3) circle (0.05) node[above]{$P$};
   \draw[red, thick] (0, 4, 0) -- (2, 4, 0);
   \draw[blue, thick] (2, 4, 0) -- (2, 4, 3);
   \draw[green, thick] (2, 0, 0) -- (2, 4, 0);

 \end{tikzpicture}
\end{document}

enter image description here

4
  • thank you so much! I'll analyse the code! One question... how can I erase the arrow in the final parts of the axis (with negative numbers)? look at the picture.
    – ryuk
    Commented Dec 26, 2018 at 15:08
  • 1
    @ryuk Change \draw[gray, -latex] (0, 0) -- (-3.5, 0); to \draw[gray] (0, 0) -- (-3.5, 0);
    – caverac
    Commented Dec 26, 2018 at 15:09
  • thanks...I mean I would like to see only one arrow for axis and not two ;)
    – ryuk
    Commented Dec 26, 2018 at 15:12
  • 1
    @ryuk Right, the change above should do it, it removes the arrow tip, but leaves the axis untouched otherwise
    – caverac
    Commented Dec 26, 2018 at 15:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .