6

I'm trying to illustrate a sensor network inside a domain. This is what I have right now:

enter image description here

Here is the code I used to generate this:

\documentclass[border=5mm]{standalone}
\usepackage{tikz}
\begin{document}
    \begin{tikzpicture}[scale=1]
        \foreach \i /\x/\y in {
            1/1/1.7320508075689,
            2/-1/1.7320508075689,
            3/-2/0,
            4/-1/-1.7320508075689,
            5/1/-1.7320508075689,
            6/2/0,
            7/4/0,
            8/4.7/0.6,
            9/4.7/-0.6
        }{
            \node [coordinate] (n\i) at (\x,\y) {\i};
        }

        \foreach \i in {1,...,9} {
            \fill (n\i) circle (1pt);
            \fill [orange,opacity=0.3] (n\i) circle (1.4142135623731);
            %\draw [red] (n\i) circle (1);
            %\draw [green] (n\i) circle (3.1622776601684);
        }
    \end{tikzpicture}
\end{document}

and what I would like to achieve is something that has this on top:

enter image description here

Would anyone have any advice on doing something like this?

  • Welcome to TeX.SE! Please add the code that you used to create this figure to the question. – Marijn Jul 5 '18 at 8:53
  • Since there are no regularities I guess the only way is to draw curves by specifying coordinates you want them to pass.. – GiuTeX Jul 5 '18 at 9:11
  • Welcome to TeX.SX! Please help us (and also you) and add a minimal working example (MWE), that illustrates your problem. Reproducing your code will be much easier when we see compilable code, starting with \documentclass and ending with \end{document}. It would be great if you add. – Bobyandbob Jul 5 '18 at 9:21
  • 1
    I can't see \documentclass and \end{document} in the question. But you already answered as well. – Bobyandbob Jul 5 '18 at 9:24
  • You're right indeed, I'll make an edit to order things. – GiuTeX Jul 5 '18 at 9:25
6

I see no other ways than drawing it by yourself with the calc library and the curve line tool for \draw command. Here I post just the partial work, you can imagine how to continue, also depending on where you want you curve to pass.

Here I just used the out in options which are explained in the tikz documentation (p. 101):

[...] if you write (a) to [out=135,in=45] (b) a curve is added to the path, which leaves at an angle of 135◦ at a and arrives at an angle of 45◦ at b. This is because the options in and out trigger a special path to be used instead of the straight line [...]

\documentclass[border=5mm]{standalone}

    \usepackage{tikz}
    \usetikzlibrary{calc}

\begin{document}
    \begin{tikzpicture}[scale=1]
        \def\radius{1.4142135623731}
        \def\posyA{1.7320508075689}
        \def\posyB{0}
        \def\posyC{0.6}

        \foreach [count=\i] \x/\y in {%
            1/\posyA,
            -1/\posyA,
            -2/\posyB,
            -1/-\posyA,
            1/-\posyA,
            2/\posyB,
            4/\posyB,
            4.7/\posyC,
            4.7/-\posyC}{%
                \node [coordinate] (n\i) at (\x,\y) {\i};
                \fill (n\i) circle (1pt);
                \fill [orange, opacity=0.3] (n\i) circle (\radius);
                }
        \draw[blue, thick] ($(n2) + (0, 1)$) to[out=180, in=180] ($(n4) - (.5, 1)$)
            to[out=0, in=250] ($(n5) + (1, -.5)$)
            to[out=0, in=250] ($(n5) + (1, -.5)$);
    \end{tikzpicture}
\end{document}

OUTPUT

The output

  • 1
    This method will certainly do! Thanks a lot for taking the time to answer! – Floyd Everest Jul 5 '18 at 9:18
  • 1
    Oh, and I recommend to use the option count in theforeach in order not to have to re-write all the times 1/, 2/, 3/ and so on! – GiuTeX Jul 5 '18 at 9:25
  • 1
    @FloydEverest if you are happy with this solution consider choosing best answer ;), you just need to click on the green check just above the voting symbols. – GiuTeX Jul 5 '18 at 9:28

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.