1

Possible Duplicate:
Simplest way to overlay a text + rectangle label an image?
Drawing on an image with TikZ

I read the following in the TikZ manual:

There are different ways of specifying coordinates. The easiest way is to say something like (10pt,2cm). This means 10pt in x-direction and 2cm in y-directions. Alternatively, you can also leave out the units as in (1,2), which means “one times the current x-vector plus twice the current y-vector.” These vectors default to 1cm in the x-direction and 1cm in the y-direction, respectively.

Say I have an image and that I want to overlay stuff on it. Is there a way to set up coordinates that are normalized to the size of the figure?

For example say I want to place a picture image.png within a tikzpicture

\begin{tikzpicture}[inner sep=0pt,remember picture]
\node at (0,0) {\includegraphics[width=0.8\linewidth]{image.png}};
\end{tikzpicture}%

I would like to use normalized coordinates when drawing nodes on top of it, such that I have the following reference frame:

   0                   1
   . -------------------> X 
   |                   | 
   |                   | 
   |       Figure      | 
   |                   | 
   |                   | 
 1 | -------------------
   V
   Y

In other words I would like to have (1,1) refer to the bottom right corner, and (0,0) refer to the upper left corner of the figure (or image).

  • 4
    This should be answered by Drawing on an image with TikZ. You might need to add a - for the y value to get this axis downwards. We were planning to produce a package for this, btw. – Martin Scharrer Apr 24 '12 at 19:22
  • @MartinScharrer: Well, the package is basically ready, it's just not on CTAN. There's an explanation how to use it at Simplest way to overlay a text + rectangle label a PNG figure? – Jake Apr 24 '12 at 19:33
  • @MartinScharrer, I am confused. I read both threads carefully before posting and I started the question because I could not get normalized coordinates when drawing. That's also why I quoted the paragraph from the TikZ manual, because according to the manual coordinates are measured by default in cm, not as normalized coordinates with respect to the content of the tikzpicture environment. – Amelio Vazquez-Reina Apr 24 '12 at 19:43
  • 2
    @roseck: Yes, by default they are. But both these solutions redefine the unit vectors so they are normalised according to the image dimensions. That's what the keys x={(image.south east)},y={(image.north west)} do in Drawing on an image with TikZ. – Jake Apr 24 '12 at 19:45
  • @roseck: Coordinates like (<unitless number>,<unitless number>) always referenced to the unit vectors. These simply happen to have an default value of 1cm, which can be easily changed, even locally. – Martin Scharrer Apr 24 '12 at 19:49
  • 2
    @roseck: If you want the y unit vector to point down, just replace anchor=south west with anchor=north west, and x={(image.south east)},y={(image.north west)} with x={(image.north east)},y={(image.south west)}. – Jake Apr 24 '12 at 19:52
  • 1
    Thanks to both, and thanks especially to @Jake! I was missing that bit. – Amelio Vazquez-Reina Apr 24 '12 at 20:07

0 Answers0