This question is slightly different from Drawing on an image with TikZ.

What I'm asking is how can I put a vertex label, at a particular point (x,y), on an image of a graph in TikZ?

\begin{center}
\begin{tikzpicture}
    \node[anchor=south west,inner sep=0 <--What is this?] at (0,0) {\includegraphics[scale=.5]{graph.png}};
    \node[???]{$v_1$};
\end{tikzpicture}
\end{center}
  • I assume you mean Drawing on an image with TikZ? The approach there can be used to place arbitrary objects on an image, not only for red rectangles on mushrooms. – Jake Aug 2 '13 at 19:56
  • Yes, but I don't know how to draw a label. – Trancot Aug 2 '13 at 19:57
  • Is it just a node? – Trancot Aug 2 '13 at 19:58
  • I think I figured it out: \node[shift={(1.0,0.3)}]{$v_1$}; – Trancot Aug 2 '13 at 20:09

You can place anything using this approach, not just rectangles.

To place text, you have to use \node at (<coordinates>) {<text>};:

\documentclass{article}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
    \node[anchor=south west,inner sep=0] (image) at (0,0) {\includegraphics[width=0.9\textwidth]{mushrooms.jpg}};
    \begin{scope}[
        x={(image.south east)},
        y={(image.north west)}
    ]
        \node [white, font=\bfseries] at (0.25,0.65) {$P(X|Y)$};
    \end{scope}
\end{tikzpicture}
\end{document}

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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