Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I would like to add a label to the axes of my plot. This is my code:

    \begin{figure}[!h]
\centering
\begin{tikzpicture}[scale=1]
  \begin{axis}[%
      % Lengend position
      legend pos = outer north east,
      % We need a tick for every data
      xtick = data,
      % The ticks label are provided in the file as the column named Num
      xticklabels from table = {test.dat}{Num}]
    % How the data are separated.
   % \pgfplotstableset{col sep = tab}
    % We need to simulate an x coord since it is litteral in the data file. I choose to index on the line.
    \addplot table [x expr = \lineno, y = Min] {test.dat};
    \addlegendentry{Min}
    \addplot table [x expr = \lineno, y = Moy] {test.dat};
    \addlegendentry{Moy}
    \addplot table [x expr = \lineno, y = Max] {test.dat};
    \addlegendentry{Max}
  \end{axis}

\end{tikzpicture}
\caption{Propagation d'une publication générée avec la politique est \bf {Amis Seulement}}
\end{figure}
share|improve this question
4  
The keys for adding labels to the axes are xlabel and ylabel. It's not too hard to find this in the manual. –  Jake May 10 '12 at 11:38
    
The tag is pgfplots –  Alain Matthes May 10 '12 at 11:45

1 Answer 1

you might do either:

  1. use xlabel and ylabel in the options part of the axis environment
  2. use \node at (axis cs:xmax,0) {your_x_label_here} and \node at (axis cs:0,ymax) {your_y_label_here}

according to me, second way is easier when you need a more accurate label location by ajusting node options...

share|improve this answer
2  
Your second approach only works if you set clip=false or use the \node command in the after end axis/.code={...}. A better way might be to use xlabel to set the label, and adjust the position using xlabel style={at=(current axis.right of origin)} or xlabel style={at=(axis cs:<x>,<y>)} –  Jake May 11 '12 at 10:07

Your Answer

 
discard

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.