
\section{\TeX{} dialects: \LaTeX{}, Con\TeX{}t, plain \TeX{}}
\label{sec:tex:dialects}

The starting point for \PGFPlots{} is an |axis| environment like |axis| or the
logarithmic variants |semilogxaxis|, |semilogyaxis| or |loglogaxis|.

Each environment is available for \LaTeX{}, Con\TeX{}t and plain \TeX{}:
%
\begin{description}
        \def\HEAD{%
            \small
            %\lstset{boxpos=b,breaklines=false,aboveskip=3pt,belowskip=3pt}%
            %\hspace{-1cm}%
            \begin{tabular}{*{2}{p{4cm}}}%
        }%
    \item[\LaTeX{}:]
        |\usepackage{pgfplots} \pgfplotsset{compat=|\pgfkeysvalueof{/pgfplots/compat/mostrecent}|}|
        and

        {\HEAD
\begin{codeexample}[code only]
\begin{tikzpicture}
\begin{axis}
...
\end{axis}
\end{tikzpicture}
\end{codeexample}
        &
\begin{codeexample}[code only]
\begin{tikzpicture}
\begin{semilogxaxis}
...
\end{semilogxaxis}
\end{tikzpicture}
\end{codeexample}
        \\
        \end{tabular}%
        }

        Here, the
        |\pgfplotsset{compat=|\pgfkeysvalueof{/pgfplots/compat/mostrecent}|}|
        key should be set to at least version 1.3. Otherwise \PGFPlots{}
        assumes that your document has been generated years ago and attempts
        to run in backwards compatibility mode as good as it can.

        Since \LaTeX{} is the default for many people, this manual only shows
        \LaTeX{} examples. A full document skeleton can be found below this
        enumeration.
    \item[Con\TeX{}t:]
        |\usemodule[pgfplots] \pgfplotsset[compat=|\pgfkeysvalueof{/pgfplots/compat/mostrecent}|]|
        and

        {\HEAD
\begin{codeexample}[code only]
\starttikzpicture
\startaxis
...
\stopaxis
\stoptikzpicture
\end{codeexample}
        &
\begin{codeexample}[code only]
\starttikzpicture
\startsemilogxaxis
...
\stopsemilogxaxis
\stoptikzpicture
\end{codeexample}
        \\
        \end{tabular}%
        }

        A complete Con\TeX{}t example file can be found in
        %
\begin{codeexample}[code only]
doc/context/pgfplots/pgfplotsexample.tex.
\end{codeexample}
        %
    \item[plain \TeX{}:]
        |\input pgfplots.tex \pgfplotsset{compat=|\pgfkeysvalueof{/pgfplots/compat/mostrecent}|}|
        and

        {\HEAD
\begin{codeexample}[code only]
\tikzpicture
\axis
...
\endaxis
\endtikzpicture
\end{codeexample}
        &
\begin{codeexample}[code only]
\tikzpicture
\semilogxaxis
...
\endsemilogxaxis
\endtikzpicture
\end{codeexample}
        \\
        \end{tabular}%
        }

        A complete plain \TeX{} example file can be found in
        %
\begin{codeexample}[code only]
doc/plain/pgfplots/pgfplotsexample.tex.
\end{codeexample}
\end{description}

For \LaTeX{}, a complete example will look somehow like this:
%
\begin{codeexample}[code only]
\documentclass[a4paper]{article}

% for dvipdfm:
%\def\pgfsysdriver{pgfsys-dvipdfm.def}
\usepackage{pgfplots}
\pgfplotsset{compat=1.6}% <-- moves axis labels near ticklabels (respects tick label widths)

\begin{document}
\begin{figure}
    \centering
    \begin{tikzpicture}
        \begin{loglogaxis}[xlabel=Cost,ylabel=Error]
            \addplot coordinates {
                (5,     8.31160034e-02)
                (17,    2.54685628e-02)
                (49,    7.40715288e-03)
                (129,   2.10192154e-03)
                (321,   5.87352989e-04)
                (769,   1.62269942e-04)
                (1793,  4.44248889e-05)
                (4097,  1.20714122e-05)
                (9217,  3.26101452e-06)
            };
            \addplot coordinates {
                (7,     8.47178381e-02)
                (31,    3.04409349e-02)
                (111,   1.02214539e-02)
                (351,   3.30346265e-03)
                (1023,  1.03886535e-03)
                (2815,  3.19646457e-04)
                (7423,  9.65789766e-05)
                (18943, 2.87339125e-05)
                (47103, 8.43749881e-06)
            };
            \legend{Case 1,Case 2}
        \end{loglogaxis}
    \end{tikzpicture}
    \caption{A larger example}
\end{figure}
\end{document}
\end{codeexample}

If you use |latex| / |dvips| or |pdflatex|, no further modifications are
necessary. For |dvipdfm|, you should use the |\def\pgfsysdriver| line as
indicated above in the examples (see also Section~\ref{sec:drivers}).
