2

I am trying to draw my first picture in tikz and I need a small help with the following. I want to draw a family of "surfaces" that consists of all the planes parallel to yz-plane, and all the individual points on the yz-plane. I drew the planes but am struggling with the points. So what I need is to fill the yz-plane with dots. Could you give me a help to fill this gap?

Below I put my code so far:

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\coordinate (O) at (0, 0, 0);
\draw[line width=0.3mm,->] (0,0,0) -- (4,0,0) node[anchor=north east]{$y$};     
\draw[line width=0.3mm,->] (0,0,0) -- (0,4,0) node[anchor=north east]{$z$};     
\draw[line width=0.3mm,->] (0,0,0) -- (0,0,7) node[anchor=east]{$x$};
\filldraw[color=blue!10!white,opacity=0.8] (0, 0, 2) -- (0, 3.5, 2) -- (2, 3.5, 2) --   (2, 0, 2) -- cycle;
\draw  (0, 0, 2) -- (0, 3.5, 2) -- (2, 3.5, 2) --   (2, 0, 2) -- cycle;
\filldraw[color=blue!10!white,opacity=0.8] (0, 0, 2.5) -- (0, 3.5, 2.5) -- (2, 3.5, 2.5) --   (2, 0, 2.5) -- cycle;
\draw  (0, 0, 2.5) -- (0, 3.5, 2.5) -- (2, 3.5, 2.5) --   (2, 0, 2.5) -- cycle;
\filldraw[color=blue!10!white,opacity=0.8] (0, 0, 3) -- (0, 3.5, 3) -- (2, 3.5, 3) --   (2, 0, 3) -- cycle;
\draw  (0, 0, 3) -- (0, 3.5, 3) -- (2, 3.5, 3) --   (2, 0, 3) -- cycle;
\filldraw[color=blue!10!white,opacity=0.8] (0, 0, 3.5) -- (0, 3.5, 3.5) -- (2, 3.5, 3.5) --   (2, 0, 3.5) -- cycle;
\draw  (0, 0, 3.5) -- (0, 3.5, 3.5) -- (2, 3.5, 3.5) --   (2, 0, 3.5) -- cycle;
\filldraw[color=blue!10!white,opacity=0.8] (0, 0, 4) -- (0, 3.5, 4) -- (2, 3.5, 4) --   (2, 0, 4) -- cycle;
\draw  (0, 0, 4) -- (0, 3.5, 4) -- (2, 3.5, 4) --   (2, 0, 4) -- cycle;
\filldraw[color=blue!10!white,opacity=0.8] (0, 0, 4.5) -- (0, 3.5, 4.5) -- (2, 3.5, 4.5) --   (2, 0, 4.5) -- cycle;
\draw  (0, 0, 4.5) -- (0, 3.5, 4.5) -- (2, 3.5, 4.5) --   (2, 0, 4.5) -- cycle;
\filldraw[color=blue!10!white,opacity=0.8] (0, 0, 5) -- (0, 3.5, 5) -- (2, 3.5, 5) --   (2, 0, 5) -- cycle;
\draw  (0, 0, 5) -- (0, 3.5, 5) -- (2, 3.5, 5) --   (2, 0, 5) -- cycle;
\filldraw[color=blue!10!white,opacity=0.8] (0, 0, 5.5) -- (0, 3.5, 5.5) -- (2, 3.5, 5.5) --   (2, 0, 5.5) -- cycle;
\draw  (0, 0, 5.5) -- (0, 3.5, 5.5) -- (2, 3.5, 5.5) --   (2, 0, 5.5) -- cycle;
\end{tikzpicture}
\end{document}

Thanks in advance!

  • Welcome to TeX.SX! Please make your code compilable (if possible), or at least complete it with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem. – dexteritas Aug 1 '17 at 14:41
  • do you like to replace fill (blue!...) with pattern of dots? see pattern library on page 666 in tikz & pgf manual (V3.0.1.a) – Zarko Aug 1 '17 at 14:48
  • @dexteritas Ups sorry I didn't think of that... I'll fix it :) – T.P. Aug 1 '17 at 14:51
  • @Zarko No, I don't want to change my planes. They are exactly what I need. I want to fill only the plane x=0 with dots. So only the plane in the backround. – T.P. Aug 1 '17 at 14:53
  • @T.P., than apply patter to this plane ... with something like \fill[pattern=dots, pattern color=gray] (0,0) ... ;, in preamble you should add \usetikzlibrary{patterns} – Zarko Aug 1 '17 at 15:20
3

I made a command \plane for the redundancies to shorten the code and added a dotted plane at x=0, using the tikzlibrary patterns and the option pattern=dots.

Note: I use \draw[fill=<color>] to draw the black border and also the filling with one command. Besides you can use rectangle to draw a rectangle between two points.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{patterns}

\begin{document}

\newcommand{\plane}[2][fill=blue!10!white]{
    \draw[opacity=0.8,#1] (0, 0, #2) rectangle (2, 3.5, #2);
}

\begin{tikzpicture}
    \coordinate (O) at (0, 0, 0);
    \draw[line width=0.3mm,->] (O) --++ (4,0,0) node[anchor=north east]{$y$};     
    \draw[line width=0.3mm,->] (O) --++ (0,4,0) node[anchor=north east]{$z$};     
    \draw[line width=0.3mm,->] (O) --++ (0,0,7) node[anchor=east]{$x$};

    \plane[draw=none,pattern=dots]{0};

    \foreach \x in {2,2.5,...,5.5}
        \plane{\x};
\end{tikzpicture}

\end{document}

enter image description here

  • Thanks a lot! It's exactly how I imagined my picture should be :D – T.P. Aug 1 '17 at 15:32
  • If you like my answer and it was helpful, please consider upvoting (by clicking on the arrows next to the score) and/or marking it as the accepted answer (by clicking on the checkmark ✓). – dexteritas Aug 2 '17 at 7:03
  • Sure, I can click the checkmark. As for the upvoating, I tried but I can't do it, I think because of my low reputation. Step by step I learn how to use this site :D – T.P. Aug 2 '17 at 22:45
0

let me convert my comment to an answer ... some how similar to dexteritas answer:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{patterns}

\usepackage[active,tightpage]{preview}% only for test
\PreviewEnvironment{tikzpicture}
    \setlength\PreviewBorder{1em}


\begin{document}
    \begin{tikzpicture}[L/.append style={line width=0.3mm,->}]
\coordinate (O) at (0, 0, 0);
\draw[L] (O) --++ (4,0,0) node[below left] {$y$};
\draw[L] (O) --++ (0,4,0) node[below left] {$z$};
\draw[L] (O) --++ (0,0,7) node[left]       {$x$};
%
\fill[pattern=dots] (O) |- (2, 3.5, 0) |- cycle;
%
\foreach \x in {2,2.5,...,5.5}
    \draw[fill=blue!10!white,opacity=0.6] (0,0,\x) |- (2,3.5,\x) |- cycle;
    \end{tikzpicture}
\end{document}

enter image description here

  • @T.P., here is habit that thankfulness is expressed by voting of answer and accepting one, which solve your problem on the best way :) – Zarko Aug 1 '17 at 21:51

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.