Possible Duplicate:
pgfplots: how can I scale to text width?
Without using such command as trim axis=left or scale only axis, I
would expect the following plots to be contained in the text area :
\documentclass{article}
\usepackage{pgfplots}
\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}
\begin{axis}[%
width=\textwidth,
height=0.3\textheight,
axis on top,
ytick=data,
yticklabels={\dots ,Happens ,Nothing ,Xyzzzzzzzzzzzzzy !}]
\pgfplotstableread{
1 4
2 4.2
3 3.1
4 2.5
}\table
\addplot[xbar] table[x index=1, y index=0]{\table};
\end{axis}
\end{tikzpicture}
\end{figure}
Some text. Some text. Some text. Some text. Some text. Some text. Some
text. Some text. Some text. Some text. Some text. Some text. Some
text. Some text. Some text. Some text. Some text. Some text. Some
text. Some text. Some text. Some text. Some text. Some text. Some
text. Some text. Some text.
\end{document}
However, it overlaps with the margins :

Do you know what am I doing wrong?
Some elements of answer: I was wrongly supposing that the width of the labels was measured. Some techniques have already been proposed to deal with this issue in this question, as pointed out by Jake in the comments.
I do not really know what I am supposed to do in this situation.
– M. Toya Sep 07 '12 at 15:21