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 want to place a lot of pictures and plots in a long document. By now, I am using figure-environment with center-environment, but the tikz-axis-plots didn't align well with included eps-pictures or tikz-pictures. I read PGFplot to occupy full \linewidth, and aligned y=axis across tikzpicture and the pgfplot-Manual (regarding alignment), and found out, that I can use ylabel style={overlay} and yticklabel style={overlay}.

To be precise, the situation is better, but images are still not aligned well. I want the left and right border of the grid to be exacly above the other boxes. See my example for illustration.

Thanks in advance.

    \documentclass{scrartcl} % Dokumentenklasse
    \usepackage[decimalsymbol=comma]{siunitx} % SI-Einheiten einheitlich setzen

    \usepackage{pgfplots,pgfmath} % Import der Plots aus Matlab
    \usepackage{tikz} % Import der Plots aus Matlab
    \usetikzlibrary{plotmarks} % Import der Plots aus Matlab
    \newlength\fheight % Plots aus Matlab immer gleich gross
    \newlength\fwidth % Plots aus Matlab immer gleich gross
    \setlength\fheight{6cm} % Plots aus Matlab immer gleich gross
    \setlength\fwidth{8cm} % Plots aus Matlab immer gleich gross
    \pgfplotsset{ % Komma statt Punkt als Dezimaltrennzeichen
      x tick label style={/pgf/number format/use comma},
      y tick label style={/pgf/number format/use comma}}

    \begin{document}
    \begin{figure}[!htb]
        \begin{center}
    \begin{tikzpicture}

    \begin{axis}[%
    scale only axis,
    width=\fwidth,
    height=\fheight,
    xmin=0, xmax=15,
    ymin=0, ymax=200,
    xlabel={$t/\SI{}{\minute}$},
    ylabel style={overlay},
    yticklabel style={overlay},
    ylabel={$d_\textrm{Nitrid}/\SI{}{\nano\meter}$},
    xmajorgrids,
    ymajorgrids,
    zmajorgrids]

    \addplot [
    color=black,
    only marks,
    mark=*,
    mark options={solid,fill=green}
    ]
    coordinates{
    (12,159.2)(12,160)(6,78.7)(6,78.7)(6,78.3)(6,77.8) 
    };
    \end{axis}
    \end{tikzpicture}
      \caption{Axis example}
        \label{asdf1}
      \end{center}
    \end{figure}



    \begin{figure}[!htb]
        \begin{center}
    \begin{tikzpicture}[even odd rule,rounded corners=2pt,x=10pt,y=10pt]
    \filldraw[fill=green] (0,0) rectangle (\fwidth,\fheight);
    \end{tikzpicture}
      \caption{Size of the pictures}
        \label{asdf2}
      \end{center}
    \end{figure}


    \end{document}
share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

What you are seeing the bounding box of the leftmost x (!) tick label: it shifts your axis to the right.

A possible solution is to use xticklabel style={overlay} as well.

However, my advice is to use

\begin{tikzpicture}[trim axis left, trim axis right]

which configures TikZ to 1. assume a following axis and 2. to skip everything left of that axis and right of that axis when it computes bounding boxes.

This approach is fairly new, and recent versions of pgfplots provide more documentation. The approach will automatically solve this kind of alignment problems (it even works together with image externalization).

share|improve this answer
    
Hello Christian, thank you very much for your answer. I found out, that my pgf-Version was outdated (tex.stackexchange.com/questions/15402/…). But with wiki.ubuntuusers.de/LATEX#Manuelle-Installation I was able to install the necessary files. –  Lukas Aug 23 '11 at 6:20
    
Sounds good. If you believe that the answer solves your question, you can mark it as "answered" to close the thread. –  Christian Feuersänger Aug 23 '11 at 17:07
    
Yes, the question is answered very well. The question can be marked as "answered" by someone who has the privilege. –  Lukas Aug 31 '11 at 11:31
add comment

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.