The Reference
\(\newcommand{\footnotename}{footnote}\) \(\def \LWRfootnote {1}\)
\(\newcommand {\footnote }[2][\LWRfootnote ]{{}^{\mathrm {#1}}}\)
\(\newcommand {\footnotemark }[1][\LWRfootnote ]{{}^{\mathrm
{#1}}}\) \(\let \LWRorighspace \hspace \) \(\renewcommand {\hspace
}{\ifstar \LWRorighspace \LWRorighspace }\) \(\newcommand
{\mathnormal }[1]{{#1}}\) \(\newcommand \ensuremath [1]{#1}\)
\(\newcommand {\LWRframebox }[2][]{\fbox {#2}} \newcommand
{\framebox }[1][]{\LWRframebox } \) \(\newcommand {\setlength
}[2]{}\) \(\newcommand {\addtolength }[2]{}\) \(\newcommand
{\setcounter }[2]{}\) \(\newcommand {\addtocounter }[2]{}\)
\(\newcommand {\arabic }[1]{}\) \(\newcommand {\number }[1]{}\)
\(\newcommand {\noalign }[1]{\text {#1}\notag \\}\) \(\newcommand
{\cline }[1]{}\) \(\newcommand {\directlua }[1]{\text
{(directlua)}}\) \(\newcommand {\luatexdirectlua }[1]{\text
{(directlua)}}\) \(\newcommand {\protect }{}\) \(\def
\LWRabsorbnumber #1 {}\) \(\def \LWRabsorbquotenumber "#1 {}\)
\(\newcommand {\LWRabsorboption }[1][]{}\) \(\newcommand
{\LWRabsorbtwooptions }[1][]{\LWRabsorboption }\) \(\def \mathchar
{\ifnextchar "\LWRabsorbquotenumber \LWRabsorbnumber }\) \(\def
\mathcode #1={\mathchar }\) \(\let \delcode \mathcode \) \(\let
\delimiter \mathchar \) \(\def \oe {\unicode {x0153}}\) \(\def \OE
{\unicode {x0152}}\) \(\def \ae {\unicode {x00E6}}\) \(\def \AE
{\unicode {x00C6}}\) \(\def \aa {\unicode {x00E5}}\) \(\def \AA
{\unicode {x00C5}}\) \(\def \o {\unicode {x00F8}}\) \(\def \O
{\unicode {x00D8}}\) \(\def \l {\unicode {x0142}}\) \(\def \L
{\unicode {x0141}}\) \(\def \ss {\unicode {x00DF}}\) \(\def \SS
{\unicode {x1E9E}}\) \(\def \dag {\unicode {x2020}}\) \(\def \ddag
{\unicode {x2021}}\) \(\def \P {\unicode {x00B6}}\) \(\def
\copyright {\unicode {x00A9}}\) \(\def \pounds {\unicode {x00A3}}\)
\(\let \LWRref \ref \) \(\renewcommand {\ref }{\ifstar \LWRref
\LWRref }\) \( \newcommand {\multicolumn }[3]{#3}\) \(\require
{textcomp}\) \( \newcommand {\meta }[1]{\langle \textit {#1}\rangle
} \) \(\newcommand {\toprule }[1][]{\hline }\) \(\let \midrule
\toprule \) \(\let \bottomrule \toprule \) \(\def
\LWRbooktabscmidruleparen (#1)#2{}\) \(\newcommand
{\LWRbooktabscmidrulenoparen }[1]{}\) \(\newcommand {\cmidrule
}[1][]{\ifnextchar (\LWRbooktabscmidruleparen
\LWRbooktabscmidrulenoparen }\) \(\newcommand {\morecmidrules }{}\)
\(\newcommand {\specialrule }[3]{\hline }\) \(\newcommand
{\addlinespace }[1][]{}\) \(\require {colortbl}\) \(\let
\LWRorigcolumncolor \columncolor \) \(\renewcommand {\columncolor
}[2][named]{\LWRorigcolumncolor [#1]{#2}\LWRabsorbtwooptions }\)
\(\let \LWRorigrowcolor \rowcolor \) \(\renewcommand {\rowcolor
}[2][named]{\LWRorigrowcolor [#1]{#2}\LWRabsorbtwooptions }\) \(\let
\LWRorigcellcolor \cellcolor \) \(\renewcommand {\cellcolor
}[2][named]{\LWRorigcellcolor [#1]{#2}\LWRabsorbtwooptions }\)
\(\newcommand {\intertext }[1]{\text {#1}\notag \\}\) \(\let \Hat
\hat \) \(\let \Check \check \) \(\let \Tilde \tilde \) \(\let
\Acute \acute \) \(\let \Grave \grave \) \(\let \Dot \dot \) \(\let
\Ddot \ddot \) \(\let \Breve \breve \) \(\let \Bar \bar \) \(\let
\Vec \vec \) \(\newcommand {\nicefrac }[3][]{\mathinner
{{}^{#2}\!/\!_{#3}}}\)
4.1 Te X
dialects:
La Te X , ConTe X t, plain
Te X
The starting point for pgfplots is an
axis environment
like axis or the
logarithmic variants
semilogxaxis ,
semilogyaxis
or loglogaxis .
Each environment is available for
La Te X , ConTe X t and plain
Te X :
La Te X :
\usepackage{pgfplots}
\pgfplotsset {compat = 1.18} and
Here, the
\pgfplotsset {compat = 1.18} 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
La Te X
is the default for many people, this manual only shows
La Te X
examples. A full document skeleton can be found below this
enumeration.
ConTe X t:
\usemodule[pgfplots]
\pgfplotsset [compat= 1.18] and
.
copy
\starttikzpicture
\startaxis
...
\stopaxis
\stoptikzpicture
copy
\starttikzpicture
\startsemilogxaxis
...
\stopsemilogxaxis
\stoptikzpicture
A complete ConTe X t example file can be found in
copy
doc/context/pgfplots/pgfplotsexample.tex.
plain
Te X :
\input pgfplots.tex
\pgfplotsset {compat = 1.18} and
.
copy
\tikzpicture
\axis
...
\endaxis
\endtikzpicture
copy
\tikzpicture
\semilogxaxis
...
\endsemilogxaxis
\endtikzpicture
A complete plain
Te X
example file can be found in
copy
doc/plain/pgfplots/pgfplotsexample.tex.
For
La Te X , a complete example will look somehow like this:
copy
\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}
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 2.6.3 ).