1

I am trying to place two nodes near a specific point on a grid, this seems simple enough but when I try:

\documentclass{article}
\usepackage{tikz}
\begin{document}
 \usetikzlibrary{calc}
 \begin{tikzpicture}[scale=1.5]
  \tikzset{microphone/.style={black,circle,draw,fill=gray,pos=0.75,scale=0.5,inner sep=2pt}};

  \coordinate (centre_of_array) at (4,1);
  \coordinate (bottom_left) at (0,0);
  \coordinate (top_right) at (7,5);
  \draw [dotted, draw=black, fill=white] (bottom_left) grid  (top_right);
  \draw [ultra thick, draw=black] (bottom_left) rectangle  (top_right);
  \node[microphone, label=below:$x_1$, left of=centre_of_array] (x1) {};
  \node[microphone, label=below:$x_2$,right of=centre_of_array] (x2) {};
 \end{tikzpicture}
\end{document} 

I get the following: Why aren't the 'microphones' placed at position (4,1) on the grid?

This seems quite simple but after a search on here I can't see anyone who's posted something similar, why aren't the 'microphones' placed either side of position (4,1) on the grid? Am I missing something?

Many thanks.

1 Answers1

1

You have defined a position in your microphone style. If you take this out, you will get what you want.

% arara: pdflatex

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc, positioning}

\begin{document}        
    \begin{tikzpicture}[scale=1.5]
    \tikzset{microphone/.style={black,circle,draw,fill=gray,scale=0.5,inner sep=2pt}};

    \coordinate (centre_of_array) at (4,1);
    \coordinate (bottom_left) at (0,0);
    \coordinate (top_right) at (7,5);
    \draw [dotted, draw=black, fill=white] (bottom_left) grid  (top_right);
    \draw [ultra thick, draw=black] (bottom_left) rectangle  (top_right);
    \node[microphone, label=below:$x_1$, left = of centre_of_array] (x1) {};
    \node[microphone, label=below:$x_2$, right = of centre_of_array] (x2) {};
    \end{tikzpicture}
\end{document} 

enter image description here

LaRiFaRi
  • 43,807