TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm new to that forum but it already helped a lot, thanks for this!

But now I really got stuck. Basically I'm looking for a possiblity to reference the xlabel of an axis in a TikZ picture. The intention is to read out the xlabel coordinates. Later on I would like to use them to position another node in a specific way with respect to the these coordinates.

With xlabel style={name=xlabel} I tried to assign the xlabel name in the axis options. Within the axis I wanted to point to it with xlabel.north (like it is possible to point to the axis itself with current axis.north).

Unfortunately it didn't work. I was told:

no shape named xlabel is known

So I guess, that naming the xlabel in the axis options is wrong. Is there a way to solve this problem?

I hope the question is stated such that one can understand what I'm trying to say...

share|improve this question
Welcome to TeX.sx! No need to add thanks, simply use upvoting to acknowledge good answers. – Peter Jansson Feb 2 '13 at 15:58
up vote 3 down vote accepted

You're probably trying to access the xlabel node before it's created (hard to tell without an example document).

If you put the drawing command inside the axis, the label won't exist yet (it gets placed only after the axis is finished). You'll have to put it outside the axis:


    xlabel=X label,
    xlabel style={name=xlabel}
  \addplot {rnd};
  \draw [ultra thick, latex-] (xlabel.south east) -- ++(1,-1);
share|improve this answer
That is exactly what I was looking for. I think case is closed :-) – caroussell Feb 3 '13 at 11:13

Assuming that you are using "pure" tikz (i.e: no pgfplots which would be a completely different issue), the idea is to name some coordinates at the ends of the line, and then build a node which contains both (using fit library). This node can be named as you required. You can only give names to nodes (and coordinates which are a particular type of dimensionless node).

Following is a MWE:


\coordinate (start) at (0,0);
\coordinate (end) at (3,0);
\draw[->] (start) -- (end);
\node[fit=(start) (end), draw=none, inner sep=1pt] (axis) {};

% The line is contained in node "axis" which we can use
\draw (axis.south) node[below] {Foo}
      (axis.east)  node[right] {Bar}
      (axis.west)  node[left]  {XX};

And produces:

enter image description here

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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