% main=manual.tex \section{Reference} \subsection{The axis--environments} There are four axis environments, \begin{enumerate} \item The axis environment for normal plots, \begin{lstlisting} \begin{axis} ... \end{axis} \end{lstlisting} \item The axis environment for logarithmic scaling of~$x$ and normal scaling of~$y$, \begin{lstlisting} \begin{semilogxaxis} ... \end{semilogxaxis} \end{lstlisting} \item The axis environment for normal scaling of~$x$ and logarithmic scaling of~$y$, \begin{lstlisting} \begin{semilogyaxis} ... \end{semilogyaxis} \end{lstlisting} \item The axis environment for logarithmic scaling of both, $x$~and~$y$ axes, \begin{lstlisting} \begin{loglogaxis} ... \end{loglogaxis} \end{lstlisting} \end{enumerate} They are all equivalent to \begin{lstlisting} \begin{axis}[ xmode=log|normal, ymode=log|normal] ... \end{axis} \end{lstlisting} with properly set variables `\texttt{xmode}' and `\texttt{ymode}' (see below). \subsection{Available markers} \label{sec:markers}% The following options of \Tikz\ may be useful for plots. \subsubsection{Markers} This list is copied from~\cite[section~29]{tikz}: \begingroup \newenvironment{longdescription}[0]{% \begin{list}{}{% \leftmargin=4.3cm \setlength{\labelwidth}{4.3cm}% \renewcommand{\makelabel}[1]{\hfill\textbf{\texttt{##1}}}% }% }{% \end{list}% }% \def\showit#1{% \tikz\draw[% gray, thin, mark options={fill=yellow!80!black,draw=black,scale=2}, x=0.8cm,y=0.3cm, #1] plot coordinates {(0,0) (1,1) (2,0) (3,1)};% }% \begin{longdescription} \item[mark=*] \showit{mark=*} \item[mark=x] \showit{mark=x} \item[mark=+] \showit{mark=+} \item[mark=ball] \showit{mark=ball} \end{longdescription} And with \lstinline!\usetikzlibrary{plotmarks}!: \begin{longdescription} \item[mark=$-$] \showit{mark=-} \item[mark=$|$] \showit{mark=|} \item[mark=o] \showit{mark=o} \item[mark=asterisk] \showit{mark=asterisk} \item[mark=star] \showit{mark=star} \item[mark=oplus] \showit{mark=oplus} \item[mark=oplus*] \showit{mark=oplus*} \item[mark=otimes] \showit{mark=otimes} \item[mark=otimes*] \showit{mark=otimes*} \item[mark=square] \showit{mark=square} \item[mark=square*] \showit{mark=square*} \item[mark=triangle] \showit{mark=triangle} \item[mark=triangle*] \showit{mark=triangle*} \item[mark=diamond] \showit{mark=diamond} \item[mark=diamond*] \showit{mark=diamond*} \item[mark=pentagon] \showit{mark=pentagon} \item[mark=pentagon*] \showit{mark=pentagon*} \end{longdescription} All these options have been drawn with the additional options \begin{lstlisting} \draw[ gray, thin, mark options={% scale=2,fill=yellow!80!black,draw=black } ] \end{lstlisting} \subsubsection{Line styles} \def\showit#1{% \tikz\draw[% black, x=0.8cm,y=0.3cm, #1] plot coordinates {(0,0) (1,1) (2,0) (3,1)};% }% The following line styles are predefined in \Tikz: \begin{longdescription} \item[style=solid] \showit{style=solid} \item[style=dotted] \showit{style=dotted} \item[style=densely dotted] \showit{style=densely dotted} \item[style=loosely dotted] \showit{style=loosely dotted} \item[style=dashed] \showit{style=dashed} \item[style=densely dashed] \showit{style=densely dashed} \item[style=loosely dashed] \showit{style=loosely dashed} \end{longdescription} You may need the option \lstinline!mark options={solid}! to avoid dotted or dashed marker boundaries. The string ``\texttt{style=}'' can be omitted. \endgroup \subsection{\texttt{\textbackslash addplot[OPTIONS] PATH}} This is the main plotting command. It is used as \begin{lstlisting} \addplot plot coordinates { (0,0) (1,1) }; \end{lstlisting} or \begin{lstlisting} \addplot[color=blue,mark=*] plot coordinates { (0,0) (1,1) }; \end{lstlisting} The first syntax chooses the next unused plot specification of the list \lstinline!\autoplotspeclist! (see below) and the second syntax specifies a plot specification explicitly. This specification will be used inside of the legend (if any). \noindent Some more details: \begin{itemize} \item You can modify \texttt{OPTIONS} with \begin{lstlisting}[gobble=1] \tikzstyle{every axis plot}=[...] \end{lstlisting} or, even better, with \begin{lstlisting}[gobble=1] \tikzstyle{every axis plot}+=[...] \end{lstlisting} \item The \texttt{OPTIONS} are remembered for the legend. \item See subsection~\ref{sec:markers} for a list of available markers and line styles. \item For log plots, \PGFPlots\ will compute the natural logarithm $\log(\cdot)$ numerically. This works with normal fixed point numbers or in scientific notation. For example, the following numbers are valid input to \lstinline!\addplot!. \begin{lstlisting} \begin{tikzpicture} \begin{loglogaxis} \addplot plot coordinate { (769, 1.6227e-04) (1793, 4.4425e-05) (4097, 1.2071e-05) (9217, 3.2610e-06) (1e6, 0.00003341) (2.3e7, 0.00131415) ; \end{loglogaxis} \end{tikzpicture} \end{lstlisting} You can represent arbirtrarily small or very large numbers as long as its logarithm can be represented as a \TeX-length (up to about~$16384$). Of course, any coordinate~$x\le 0$ is not possible since the logarithm of a non-positive number is not defined. Such coordinates will be skipped automatically. \item For normal plots, \PGFPlots\ understands arbirtrarily large or small numbers like 0.00000001234 or $1.234\cdot 10^{24}$. \PGFPlots\ has its own number parsing tools which are complete text based and do not rely on \TeX's limited numerical number representation. Before the plots are actually drawn, any input coordinate is transformed into \TeX-precision using transformations \[ T_x(x) = 10^{s_x} \cdot x \text{ and } T_y(y) = 10^{s_y} \cdot y \] with properly chosen integers $s_x, s_y \in \Z$. This ensures invariance of axis ranges. See section~\ref{sec:disabledatascaling} for more details. \item As a consequence of the coordinate parsing routines, you can't use the mathematical expression parsing method of \PGF\ as coordinates (that means: you will need to provide coordinates without suffixes like ``cm'' or ``pt'' and you can't invoke mathematical functions). \item If you did not specify axis limits for $x$ and $y$ manually, \lstinline!\addplot! will compute them automatically. The automatic computation of axis limits works as follows: \begin{enumerate} \item In case of \lstinline!\addplot plot coordinates {...};!, every coordinate will be checked. Any other \Tikz-plot mode is not (yet) supported (had no time yet). \item Since more than one \lstinline!\addplot! command may be used inside an \lstinline!\begin{axis}...\end{axis}!, all drawing commands will be postponed until \lstinline!\end{axis}!. See the \lstinline!\axispath!-command for more information about automatic axis limits and the postponed drawing. \end{enumerate} \end{itemize} \subsection{\texttt{\textbackslash addplot+[OPTIONS] ...}} Does the same like \lstinline!\addplot[OPTIONS] ...! except that \texttt{OPTIONS} is \emph{appended} to the arguments which would have been taken for \lstinline!\addplot ...! (the element of the default list). Example: \begin{lstlisting} \addplot+[only marks] plot coordinates {...}; \end{lstlisting} will use the same line style, markers, colors as \begin{lstlisting} \addplot plot coordinates {...}; \end{lstlisting} but it will only draw markers, no lines. \subsection{\texttt{\textbackslash axispath...;}} \label{sec:axispath}% This command allows to draw custom content into an axis. The argument to \lstinline!\axispath! may be any \Tikz-command like \begin{lstlisting} \axispath\node at (axis cs:12.14368,-9.30872) {}; \end{lstlisting} or \begin{lstlisting} \axispath\draw (axis cs:12.14368,-9.30872) -- (axis cs:0,1); \end{lstlisting} A useful example is presented in section~\ref{sec:annot:plot} where annotations are placed near some data points. The \lstinline!\axispath! command is necessary to communicate drawing commands to \PGFPlots. If \PGFPlots\ needs to determine the $x$~and/or~$y$ limits automatically, any plotting commands (including those with \lstinline!\axispath!) will be postponed until \lstinline!\end{axis}!. A missing \lstinline!\axispath! may corrupt your graphics because the clipping area may not yet be known. The ``\texttt{axis cs}'' coordinate system allows you to access axis coordinates. You can use the same numbers as in \lstinline!\addplot! all required transformations like logarithms or data scaling transformations will be applied. All \lstinline!\axispath! commands should use these coordinate systems. See section~\ref{sec:axis:coords} for more information and section~\ref{sec:annot:plot} for examples. \subsection{Accessing axis coordinates with \texttt{axis cs}} \label{sec:axis:coords}% \PGFPlots\ provides a new coordinate system for use inside of an axis, the ``axis coordinate system'', \texttt{axis cs}. Its can be used in conjunction with \lstinline!\axispath! to draw any \Tikz-graphics at axis coordinates. It is used like \begin{lstlisting} \axispath\draw (axis cs:18943,2.873391e-05) |- (axis cs:47103,8.437499e-06); \end{lstlisting} see section~\ref{sec:annot:plot} for example graphics. \paragraph{Attention:} Whenever you draw additional graphics, consider using \texttt{axis cs}! It applies any logarithms, data scaling transformations or whatever \PGFPlots\ usually does! \subsection{\texttt{\textbackslash addlegendentry\{name\}}} Adds a single legend entry to the legend list. Example: \begin{lstlisting} \begin{tikzpicture} \begin{axis} \addplot[smooth,mark=*,blue] plot coordinates { (0,2) (2,3) (3,1) }; \addlegendentry{Case 1} \addplot[smooth,color=red,mark=x] plot coordinates { (0,0) (1,1) (2,1) (3,2) }; \addlegendentry{Case 2} \end{axis} \end{tikzpicture} \end{lstlisting} The outcome of this listing is shown in figure~\ref{fig:addlegendentry}. \begin{figure} \centering \begin{tikzpicture} \begin{axis} \addplot[smooth,mark=*,blue] plot coordinates { (0,2) (2,3) (3,1) }; \addlegendentry{Case 1} \addplot[smooth,color=red,mark=x] plot coordinates { (0,0) (1,1) (2,1) (3,2) }; \addlegendentry{Case 2} \end{axis} \end{tikzpicture} \caption{An example for the \texttt{\textbackslash addlegendentry} command}% \label{fig:addlegendentry}% \end{figure}% It does not matter where \lstinline[breaklines=false]!\addlegendentry! commands are placed, only the sequence matters. You will need one \lstinline[breaklines=false]!\addlegendentry! for every \lstinline!\addplot! command. \subsection{\texttt{\textbackslash legend[OPTIONS]\{LIST\}}} \label{sec:legenddef}% You can use \begin{lstlisting} \begin{tikzpicture} \begin{axis} ... \legend{$d=2$\\$d=3$\\$d=4$\\$d=5$\\$d=6$\\} ... \end{axis} \end{tikzpicture} \end{lstlisting} to assign a complete legend. \textbf{Attention:} the final \lstinline!\\! is necessary! The \lstinline[breaklines=false]!\legend! command takes the following arguments: \begin{lstlisting} \legend[OPTIONS]{TEXT1\\TEXT2\\TEXT3\\...\\} \end{lstlisting} where each legend element needs to be terminated by \lstinline[breaklines=false]!\\!. The short marker/line combination shown in legends is acquired from the argument to \lstinline[breaklines=false]!\addplot[...]!. \subsubsection{Legend appearance} The style ``\texttt{every axis legend}'' determines the legend's position and outer appearance: \begin{lstlisting} \tikzstyle{every axis legend}+=[ at={(0,0)}, anchor=south west] \end{lstlisting} will draw it at the lower left corner of the axis while \begin{lstlisting} \tikzstyle{every axis legend}+=[ at={(1,1)}, anchor=north east] \end{lstlisting} means the upper right corner. The `\texttt{anchor}' option determines which point \emph{of the legend} will be placed at $(0,0)$ or $(1,1)$ (see below for more examples). The legend is a \Tikz-matrix, so you can use any \Tikz\ option which affects nodes and matrizes (see~\cite[section 13~and~14]{tikz}). The matrix is created by something like \begin{lstlisting} \matrix[style=every axis legend] { draw plot specification 1 & \node{legend 1}\\ draw plot specification 2 & \node{legend 2}\\ ... }; \end{lstlisting} You can configure the number of horizontal legend entries with the axis-option ``\texttt{legend columns=NUMBER}''. For example, \begin{lstlisting} \begin{tikzpicture} \begin{axis}[legend columns=4] ... \legend{legend 1\\legend 2\\legend 3\\} \end{axis} \end{tikzpicture} \end{lstlisting} would use (up to)~$4$ adjacent legend entries. Examples: \begin{itemize} \item \begin{lstlisting} \tikzstyle{every axis legend}+=[ at={(1.02,1)}, anchor=north west] \end{lstlisting} draws the legend OUTSIDE TOP RIGHT. \item \begin{lstlisting} \tikzstyle{every axis legend}+=[ at={(1,0.5)}, anchor=east,outer sep=0.5cm] \end{lstlisting} draws the legend INSIDE MIDDLE RIGHT, separated by 0.5cm from the axis. \end{itemize} \noindent The default is \begin{lstlisting} \tikzstyle{every axis legend}=[% cells={anchor=center}, inner xsep=3pt,inner ysep=2pt,nodes={inner sep=2pt,text depth=0.15em}, anchor=north east,% shape=rectangle,% fill=white,% draw=black, at={(0.98,0.98)} ] \end{lstlisting} \paragraph{Attention:} you should \emph{not reset} the default style to stay compatible with future versions. If possible, use \begin{lstlisting} \tikzstyle{every axis legend}+=[...] \end{lstlisting} \subsection{\texttt{\textbackslash autoplotspeclist}} Allows to specify a list of plot specifications which will be used for each \lstinline!\addplot!-command without explicit plot specification. There are several possiblities to change it: \begin{enumerate} \item Use one of the predefined lists, \begin{lstlisting} \listcopy\coloredplotspeclist\to\autoplotspeclist% \listcopy\blackwhiteplotspeclist\to\autoplotspeclist% \end{lstlisting} \item Define your own one, \begin{lstlisting} \listnew{\autoplotspeclist}{% blue,mark=*\\% red,mark=square\\% dashed,mark=o\\% loosely dotted,mark=+\\% brown!60!black,mark options={fill=brown!40},mark=otimes*\\% } \end{lstlisting} (This example list requires \lstinline!\usetikzlibrary{plotmarks}!). \end{enumerate} Please note that the `\lstinline!\\!' is required to separate each element. Please note that comment characters~`\%' are necessary if the elements are on different lines. \subsection{\texttt{\textbackslash logtologten\{ARG\}}} Expands to the result of $\texttt{ARG}/\log(10)$. You can also use \begin{lstlisting} \logtologtentomacro{9.5}{\result} \end{lstlisting} and \lstinline!\result! will be filled with the result. \subsection{\texttt{\textbackslash logten}} Expands to the constant $\log(10)$. Useful for logplots because $\log(10^i) = i\log(10)$. \subsection{\texttt{\textbackslash prettyprintnumber\{NUM\}}} Allows to generate pretty--printed output for the number \texttt{NUM}. Examples: \begin{lstlisting} \prettyprintnumber{1.0} \prettyprintnumber{151.015341} \prettyprintnumber{90.99999} \end{lstlisting} results in \prettyprintnumber{1.0}, \prettyprintnumber{151.015341}, \prettyprintnumber{90.99999}. It is used to display axis ticks. The default rounding precision is defined by \begin{lstlisting} \def\prettyprintnumberprecision{2} \end{lstlisting} and can be reconfigured if needed (the highest precision is~$5$ due to \TeX's restricted numerical capabilities). \subsection{\texttt{\textbackslash axispreset\{key=value,key=value\}}} Allows to define default options for any axis. For example, \begin{lstlisting} ... \axispreset{width=\textwidth}% ... \begin{tikzpicture} \begin{axis} ... \end{axis} \end{tikzpicture} \end{lstlisting} will produce a width of \lstinline!\textwidth! for any following axis. You can preset any of the \texttt{axis}-options described below. \subsection{Axis options} There are several required and even more optional arguments to modify axes. They are used like \begin{lstlisting} \begin{tikzpicture} \begin{axis}[key=value,key2=value2] ... \end{axis} \end{tikzpicture} \end{lstlisting} The overall appeareance can be changed with \begin{lstlisting} \tikzstyle{every axis}+=[line width=1pt] \end{lstlisting} for example. \subsubsection{\texttt{[xy]min=COORD}, \texttt{[xy]max=COORD}} The options \texttt{xmin}, \texttt{xmax} and \texttt{ymin}, \texttt{ymax} allow to define the axis limits, i.e. the lower left and the upper right corner. Some remarks: \begin{itemize} \item The axis limits determine the plotted range. Everything else will be clipped away. \item The width of every unit $x$-coordinate will be scaled such that the plot has width \lstinline!\axisdefaultwidth! (including the tick- and axis labels). The height of every unit $y$-coordinate will be scaled such that the plot has height \lstinline!\axisdefaultheight!. You can override this default behavior with the options \lstinline!width=DIMEN!, \lstinline!height=DIMEN!, \lstinline!x=DIMEN! and \lstinline!y=DIMEN!, see below. \item If one of \lstinline!xmin! or \lstinline!xmax! is missing, the $x$-interval will be determined automatically (see \lstinline!\addplot!). The same holds true if one of \lstinline!ymin! or \lstinline!ymax! is missing: in this case, the $y$-interval will be determined automatically. \item The option \lstinline!enlargelimits! will automatically increase the plotted range. \end{itemize} \subsubsection{\texttt{[xy]label=TEXT}} The options \texttt{xlabel} and \texttt{ylabel} change axis labels to `\texttt{TEXT}' which is any \LaTeX\ text. Use `\lstinline!{TEXT}!' if you need grouping. Labels are \Tikz-Nodes which are placed with \begin{lstlisting} \node [style=every axis label, style=every axis x label] \node [style=every axis label, style=every axis y label] \end{lstlisting} so you can reconfigure their position and appearance. As for legends, the coordinate \lstinline!(0,0)! denotes the lower left axis corner and \lstinline!(1,1)! the upper right. The default styles are \begin{lstlisting} \tikzstyle{every axis label}=[] \tikzstyle{every axis x label}=[ at={(0.5,0)}, below, yshift=-15pt] \tikzstyle{every axis y label}=[ at={(0,0.5)}, xshift=-35pt, rotate=90] \end{lstlisting} You should use \begin{lstlisting} \tikzstyle{every axis label}+=[...] \tikzstyle{every axis x label}+=[...] \tikzstyle{every axis y label}+=[...] \end{lstlisting} to modify options to ensure compatibility with future versions. \subsubsection{\texttt{title=TEXT}} Adds a caption to the plot. This will place a \Tikz-Node with \begin{lstlisting} \node[style=every axis title] {TEXT}; \end{lstlisting} to the current axis. An example is shown in figure~\ref{fig:titleexample}. The title is placed in the middle of the axis (the placing does not incorporate any axis descriptions). You can reconfigure the appearance and/or placing of the title for example with \begin{lstlisting} \tikzstyle{every axis title}+=[at={(0.75,1)}] \end{lstlisting} This will place the title at~75\% of the $x$-axis. The coordinate~$(0,0)$ is the lower left corner and~$(1,1)$ the upper right one. Please note that using the \LaTeX\ floating figures together with \lstinline!\caption{TEXT}! may be more appropriate in many situation. However, `\texttt{title}' allows access to the axis' size without any axis descriptions which is useful if more than one plot needs a caption. \begin{figure} \centering \begin{tikzpicture} \begin{loglogaxis}[ width=0.48\textwidth, xlabel=Dof,ylabel=Error, title={$\mu=0.1$, $\sigma=0.2$}] \addplot plot coordinates { (5, 8.312e-02) (17, 2.547e-02) (49, 7.407e-03) (129, 2.102e-03) (321, 5.874e-04) (769, 1.623e-04) (1793, 4.442e-05) (4097, 1.207e-05) (9217, 3.261e-06) }; \end{loglogaxis} \end{tikzpicture}% \hfill \begin{tikzpicture} \begin{loglogaxis}[ width=0.48\textwidth, xlabel=Dof,ylabel=Error, title={$\mu=1$, $\sigma=\frac{1}{2}$}] \addplot[color=red,mark=*] plot coordinates { (7, 8.472e-02) (31, 3.044e-02) (111, 1.022e-02) (351, 3.303e-03) (1023, 1.039e-03) (2815, 3.196e-04) (7423, 9.658e-05) (18943, 2.873e-05) (47103, 8.437e-06) }; \end{loglogaxis} \end{tikzpicture} \begin{lstlisting} \begin{tikzpicture} \begin{loglogaxis}[ width=0.48\textwidth, xlabel=Dof,ylabel=Error, title={$\mu=0.1$, $\sigma=0.2$}] \addplot plot coordinates { (5, 8.312e-02) (17, 2.547e-02) ... (4097, 1.207e-05) (9217, 3.261e-06) }; \end{loglogaxis} \end{tikzpicture}% \hfill \begin{tikzpicture} \begin{loglogaxis}[ width=0.48\textwidth, xlabel=Dof,ylabel=Error, title={$\mu=1$, $\sigma=\frac{1}{2}$}] \addplot[color=red,mark=*] plot coordinates { (7, 8.472e-02) (31, 3.044e-02) ... (18943, 2.873e-05) (47103, 8.437e-06) }; \end{loglogaxis} \end{tikzpicture} \end{lstlisting} \caption{An example for the `\texttt{title}' option. Some data points have not been listed, the `\texttt{...}' is not part of the plot.} \label{fig:titleexample} \end{figure} \subsubsection{\texttt{[xy]mode=normal$|$log}} Allows to choose between normal plots or logplots for each $x,y$-combination. Default is \lstinline!xmode=normal!, \lstinline!ymode=normal!. \subsubsection{\texttt{[xy]tick=\{LIST\}}} The options \texttt{xtick} and \texttt{ytick} assigns a list of \emph{Positions} where ticks shall be placed. The argument \texttt{LIST} will be used inside of a \lstinline!\foreach \x in {LIST}! statement, and \texttt{LIST} contains one of the following formats: \begin{itemize} \item \lstinline!{0,1,2,5,8}! (a series of coordinates), \item \lstinline!{0,...,5}! (the same as \lstinline!{0,1,2,3,4,5}!), \item \lstinline!{0,2,...,10}! (the same as \lstinline!{0,2,4,6,8,10}!), \item \lstinline!{9,...,3.5}! (the same as \lstinline!{9, 8, 7, 6, 5, 4}!), \item See \cite[Section~34]{tikz} for a more detailed definition of the options. \item Use `\texttt{xtick=}' to use the default tick placement rules. \item Use `\lstinline!xtick=\empty!' to disable any ticks. \end{itemize} For logplots, \PGFPlots\ will apply $\log(\cdot)$ to each element in `\texttt{LIST}'. \paragraph{Attention:} You can't use the `\texttt{...}' syntax if the elements are too large for \TeX! For example, `\texttt{xtick=1.5e5,2e7,3e8}' will work (because the elements are interpreted as strings, not as numbers), but `\texttt{xtick=1.5,3e5,...,1e10}' will fail because it involves real number arithmetics beyond \TeX's capacities. \vspace*{0.3cm} \noindent The default choice for tick \emph{positions} in normal plots is to place a tick at each coordinate~$i\cdot h$. The step size~$h$ depends on the axis scaling and the axis limits. It is chosen from a list a ``feasable'' step sizes such that neither too much nor too few ticks will be generated. The default for logplots it to place ticks at each $10^i$ in the axis' range. The default tick positions can be reconfigured with \begin{itemize} \item \lstinline!\renewcommand{\axisdefaulttickwidth}{35}! where the integer argument denotes the maximum space between adjacent ticks in full points. The suffix ``\texttt{pt}'' has to be omitted and fractional numbers are not supported. \item \lstinline!\renewcommand{\axisdefaulttryminticks}{4}! configures a loose lower bound on the number of ticks. It should be considered as a suggestion, not a tight limit. \end{itemize} \noindent The tick \emph{appearance} can be (re-)configured with \begin{lstlisting} \tikzstyle{every tick}=[very thin,gray] \tikzstyle{every minor tick}=[] \end{lstlisting} or \begin{lstlisting} \tikzstyle{every tick}+=[very thin,gray] \tikzstyle{every minor tick}+=[black] \end{lstlisting} Please prefer the `\texttt{+=}' versions to ensure compatibility with future versions. This style commands can be used at any time. The tick line width can be configured with the \lstinline!axis!-options `\texttt{tickwidth}' and `\texttt{subtickwidth}'. \subsubsection{\texttt{[xy]tickten=\{LIST\}}} The options \texttt{xtickten} and \texttt{ytickten} allow to place ticks at selected positions $10^k, k \in \text{\texttt{LIST}}$. They are only used for logplots. The syntax for `\texttt{LIST}' is the same as above for `\texttt{xtick=LIST}' or `\texttt{ytick=LIST}'. \subsubsection{\texttt{[xy]ticklabels=\{LIST\}}} Assigns a \emph{list} of tick \emph{labels} to each tick position. Tick \emph{positions} are assigned using the \texttt{xtick} and \texttt{ytick}-options. This is one of two options to assign tick labels directly. The other option is `\texttt{xticklabel=\{COMMAND\}}' (or \texttt{yticklabel=\{COMMAND\}}). Option `\texttt{\*ticklabel}' offers higher flexibility while `\texttt{\*ticklabels}' is easier to use. The argument \texttt{LIST} has the same format as for ticks, that means \begin{lstlisting} xticklabels={$\frac{1}{2}$,$e$} \end{lstlisting} Denotes the two--element--list $\{\frac 12, e\}$. The list indices match the indices of the tick positions. If you need commas inside of list elements, use \begin{lstlisting} xticklabels={{0,5}, $e$}. \end{lstlisting} Example: \begin{lstlisting} \begin{tikzpicture} \begin{axis}[ xtick={-1.5,-1,...,1.5}, xticklabels={% $-1\frac 12$, $-1$, $-\frac 12$, $0$, $\frac 12$, $1$} ] \addplot[smooth,blue,mark=*] plot coordinates { (-1, 1) (-0.75, 0.5625) (-0.5, 0.25) (-0.25, 0.0625) (0, 0) (0.25, 0.0625) (0.5, 0.25) (0.75, 0.5625) (1, 1) }; \end{axis} \end{tikzpicture} \end{lstlisting} yields figure~\ref{fig:ticklistexample}. \begin{figure} \centering \begin{tikzpicture}[baseline] \begin{axis}[ anchor=north east, width=6cm, xtick={-1.5,-1,...,1.5}, xticklabels={% $-1\frac 12$, $-1$, $-\frac 12$, $0$, $\frac 12$, $1$} ] \addplot[smooth,blue,mark=*] plot coordinates { (-1, 1) (-0.75, 0.5625) (-0.5, 0.25) (-0.25, 0.0625) (0, 0) (0.25, 0.0625) (0.5, 0.25) (0.75, 0.5625) (1, 1) }; \end{axis} \end{tikzpicture} \hspace{10pt}% \begin{minipage}[t]{6cm}% \vspace{0pt}% \begin{lstlisting} xtick={-1.5,-1,...,1.5}, xticklabels={% $-1\frac 12$, $-1$, $-\frac 12$, $0$, $\frac 12$, $1$} \end{lstlisting} \end{minipage} \caption{An example for the \texttt{xticklabels} option.} \label{fig:ticklistexample} \end{figure} \subsubsection{\texttt{[xy]ticklabel=\{COMMAND\}}} Use \texttt{xticklabel} or \texttt{yticklabel} to change the \LaTeX-command which creates the tick \emph{labels} assigned to each tick position (see options \texttt{xtick} and \texttt{ytick}). This is one of two options to assign tick labels directly. The other option is `\texttt{xticklabels=\{LIST\}}' (or \texttt{yticklabels=\{LIST\}}). Option `\texttt{\*ticklabel}' offers higher flexibility while `\texttt{\*ticklabels}' is easier to use. The argument `\texttt{COMMAND}' can be any \LaTeX-text. The following commands are valid inside of \texttt{COMMAND}: \begin{description} \item[\textbackslash tick] The current element of option \lstinline!xtick! (or \lstinline!ytick!). \item[\textbackslash ticknum] The current tick number, starting with~0 (a counter). \end{description} The default argument is \begin{itemize} \item \lstinline!\axisdefaultticklabel! for normal plots and \item \lstinline!\axisdefaultticklabellog! for logplots, see below. \end{itemize} (the same holds for \lstinline!yticklabel!). The defaults are set to \begin{lstlisting} \newcommand{\axisdefaultticklabel}[0]{% $\prettyprintnumber{\tick}$% } \newcommand{\axisdefaultticklabellog}[0]{{% \logtologtentomacro{\tick}{\roundedtick}% $10^{\prettyprintnumber{\roundedtick}}$% }} \end{lstlisting} You can change the appearance of tick labels with \begin{lstlisting} \tikzstyle{every tick label}+=[font=\tiny] \end{lstlisting} and/or \begin{lstlisting} \tikzstyle{every x tick label}+=[above] \end{lstlisting} and \begin{lstlisting} \tikzstyle{every y tick label}+=[font=\bfseries] \end{lstlisting} \subsubsection{\texttt{tickpos=left$|$right$|$both}} Allows to choose where to place the small tick lines. Default is ``\texttt{both}''. This setting applies to both $x$~and~$y$ axis where ``left'' and ``right'' mean ``bottom'' and ``top'' for~$y$. \subsubsection{\texttt{[xy]minorticks=true$|$false}} \subsubsection{\texttt{[xy]majorticks=true$|$false}} \subsubsection{\texttt{ticks=minor$|$major$|$both$|$none}} Enables/disables the small tick lines either for single axis or for all of them. Major ticks are those placed at the tick positions and minor ticks are only used in log plots. Please note that minor ticks are automatically disabled if \texttt{xtick} is not a uniform range\footnote{A uniform list means the difference between all elements is~$1$ for normal plots or, for logplots, $\log(10)$.}. Default is to use minor and major ticks. You can configure the length of the tick line with `\texttt{minor tick length=DIMEN}' and `\texttt{major tick length=DIMEN}' (where DIMEN is a \TeX-length like 1cm) and its appearance using the following styles: \begin{lstlisting} \tikzstyle{every tick}+=[color=black] % applies to major and minor ticks, \tikzstyle{every minor tick}+=[thin] % applies only to minor ticks, \tikzstyle{every major tick}+=[thick] % applies only to major ticks. \end{lstlisting} There is also the style ``\texttt{every tick}'' which applies to both, major and minor ticks. \subsubsection{\texttt{major tick length=DIMEN}} \subsubsection{\texttt{minor tick length=DIMEN}} Allows to configure the length of the small tick lines. Minor ticks are only displayed for logarithmic plots. See option ``\texttt{ticks}'' for appearance styles for ticks. \subsubsection{\texttt{[xy]minorgrids=true$|$false}} \subsubsection{\texttt{[xy]majorgrids=true$|$false}} \subsubsection{\texttt{grid=minor$|$major$|$both$|$none}} Enables/disables different grid lines. Major grid lines are placed at the normal tick positions (see \texttt{xmajorticks}) while minor grid lines are placed at minor ticks (see \texttt{xminorticks}). Grid lines will be drawn before tick lines are processed, so ticks will be drawn on top of grid lines. You can configure the appearance of grid lines with the styles \begin{lstlisting} \tikzstyle{every axis grid}=[style=help lines] % applies to major and minor grids, \tikzstyle{every minor grid}+=[color=blue] % applies only to minor grid lines, \tikzstyle{every major grid}+=[thick] % applies only to major grid lines. \end{lstlisting} An example for grid lines can be found in section~\ref{sec:gridlines}. \subsubsection{\texttt{enlargelimits=[true$|$false$|$auto$|$VAL]}} Enlarges the axis size somewhat if enabled. You can set \texttt{xmin}, \texttt{xmax} and \texttt{ymin}, \texttt{ymax} to the minimum/maximum values of your data and \texttt{enlargelimits} will enlarge the canvas such that the axis doesn't touch the plots. \begin{itemize} \item The value \texttt{true} enlarges all axes. \item The value \texttt{false} uses tight axis limits as specified by the user (or read from input coordinates). \item The value \texttt{auto} will enlarge limits only for axis for which axis limits have been determined automatically. \item All other values like `\texttt{enlargelimits=0.1}' will enlarge all axis limits relatively (in this example, 10\% of the axis limits will be added at all sides). \item If no relative threshold is provided, axis enlargement is done relatively to $x_\text{max}-x_\text{min}$ for normal plots and absolutely for log--plots up to now. \end{itemize} A small value of \texttt{enlargelimits} may avoid problems with large markers near the boundary. \subsubsection{\texttt{legend columns=NUMBER}} Allows to configure the maximum number of adjacent legend entries. The default is \texttt{legend columns=1}, so legends are placed vertically below each other. Examples can be found in section~\ref{sec:legendexamples:cols}. \subsubsection{\texttt{legend plot pos=left$|$right$|$none}} Configures where the small line specifications will be drawn: left of the description, right of the description or not at all. See an example in section~\ref{sec:legendexamples:plotpos}. \subsubsection{\texttt{disablelogfilter}} Disables numerical evaluation of $\log(x)$ in \LaTeX. If you specify this option, any plot coordinates and tick positions must be provided as $\log(x)$ instead of $x$. This may be faster and -- possibly -- more accurate than the numerical log. The current implementation of $\log(x)$ normalizes~$x$ to $m\cdot 10^e$ and computes \[ \log(x) = \log(m) + e \log(10) \] where $y = \log(m)$ is computed with a newton method applied to $\exp(y) - m$. The normalization involves string parsing without \TeX-registers. You can savely evaluate $\log(1\cdot 10^{-7})$ although \TeX-registers would produce an underflow for such small numbers. The exponential function is implemented in pgf using a truncated Euler McLaurin--series. The current implementation of $\log(\cdot)$ is done by the macro \lstinline!\pgfmathlog! which is provided by package \lstinline!pgfmathlog.sty! (contained in the \PGFPlots-bundle). \subsubsection{\texttt{disabledatascaling}} \label{sec:disabledatascaling}% Disables internal re-scaling of input data. Normally, every input data like plot coordinates, tick positions or whatever, are parsed without using \TeX's limited number precision. Then, a transformation like \[ T(x) = 10^{q-m} \cdot x \] is applied to every input coordinate/position where $m$ is ``the order of $x$'' base~$10$. Example: $x=1234 = 1.234\cdot 10^3$ has order~$m=4$ while $x=0.001234 = 1.234\cdot 10^{-3}$ has order $m=-2$. The parameter~$q$ is the order of the axis' width/height. The \textbf{effect} is that your plot coordinates can be of \emph{arbitrary precision} like $0.0000001$ and $0.0000004$. For these two coordinates, \PGFPlots\ will use 100pt and 400pt internally. The transformation is quit fast since it relies only on period shifts. The option ``\texttt{disabledatascaling}'' disables this data transformation. That means you are restricted to coordinates which \TeX\ can handle\footnote{Please note that the axis' scaling requires to compute $1/( x_\text{max} - x_{\text{min}} )$. The option \texttt{disabledatascaling} may lead to overflow or underflow in this context, so use it with care! Normally, the data scale transformation avoids this problem.}. So far, the data scale transformation applies only to normal axis (logarithmic scales do not need it). \subsubsection{\texttt{anchor=NAME}} This option shifts the axis horizontally and vertically such that the axis anchor (a point on the axis) is placed at coordinate $(0,0)$\footnote{I haven't understood how to implement an axis as a path command. In the future, the last path coordinate may be used in this place.}. \begin{itemize} \item Anchors are useful in conjunction with horizontal or vertical alignment of plots, see the examples in section~\ref{sec:align} and section~\ref{sec:halign}. \item Anchors are placed on the axis rectangle; any axis labels, titles or legends are completely unaffected. \item Valid choices for \texttt{NAME} are \texttt{north}, \texttt{north west}, \texttt{west}, \texttt{south west}, \texttt{south}, \texttt{south east}, \texttt{east}, \texttt{north east}, \texttt{center}. They denote the places \begin{center} \begin{tikzpicture}[x=3cm,y=3cm] \draw (0,0) rectangle (1,1); \node[above] at (0.5,1) {N}; \node[above left] at (0,1) {NW}; \node[left] at (0,0.5) {W}; \node[below left] at (0,0) {SW}; \node[below] at (0.5,0) {S}; \node[below right] at (1,0) {SE}; \node[right] at (1,0.5) {E}; \node[above right] at (1,1) {NE}; \node at (0.5,0.5) {C}; \end{tikzpicture} \end{center} \item The default value is \texttt{anchor=south west}. \end{itemize} \subsubsection{\texttt{width=DIMEN}, \texttt{height=DIMEN}} The axis is always scaled such that its dimension is {\centering\lstinline!(\axisdefaultwidth,\axisdefaultheight)!. }% \noindent The options \lstinline!width=DIMEN! and \lstinline!height=DIMEN! override the default scaling. If just one of them is specified, the other one is scaled such that the aspect ratio stays the same. \noindent\underline{Remarks:} \begin{itemize} \item The scaling only affects the width of one unit in $x$-direction or the height for one unit in $y$-direction. Axis labels and tick labels won't be resized, but their size is used to determine the axis scaling. \item You can use the \Tikz-\lstinline!scale=NUMBER! option, \begin{lstlisting} \begin{tikzpicture}[scale=2] \begin{axis} ... \end{axis} \end{tikzpicture} \end{lstlisting} to scale the complete picture. \item The \Tikz-options \lstinline!x! and \lstinline!y! which set the unit dimensions in $x$ and $y$ directions can be specified as arguments to \lstinline!\begin{axis}[x=1.5cm,y=2cm]! if needed (see below). These settings override the \lstinline!width! and \lstinline!height! options. \item You can also force a fixed width/height of the axis (without looking at labels) with \begin{lstlisting} \begin{tikzpicture} \begin{axis}[width=5cm,scale only axis] ... \end{axis} \end{tikzpicture} \end{lstlisting} \item Use \begin{lstlisting} \renewcommand{\axisdefaultwidth}{3cm} \renewcommand{\axisdefaultheight}{6cm} \begin{axis} ... \end{axis} \end{lstlisting} to replace the default dimension. \item Please note that up to the writing of this manual, \PGFPlots\ only estimates the size needed for axis- and tick labels. It does not include legends which have been placed outside of the axis\footnote{I.e. the `\texttt{width}' option will not work as expected, but the bounding box is still ok.}. This may be fixed in future versions. Use the \lstinline!x=DIMEN!, \lstinline!y=DIMEN! and \lstinline!scale only axis! options if the scaling happens to be wrong. \end{itemize} \subsubsection{\texttt{scale only axis=[true$|$false]}} This boolean option allows to apply \texttt{width} and \texttt{height} only to the axis rectangle. If `\texttt{scale only axis}' is enabled, label, tick and legend dimensions won't influence the size of the axis rectangle. If \texttt{scale only axis=false} (the default), \PGFPlots\ will try to produce the desired width \emph{including} labels, titles and ticks. \subsubsection{\texttt{x=DIMEN}, \texttt{y=DIMEN}} Use \begin{lstlisting} \begin{tikzpicture} \begin{axis}[x=1.5cm,...] ... \end{axis} \end{tikzpicture} \end{lstlisting} to set the unit size for one $x$-coordinate to 1.5cm. The same is possible for the $y$-coordinate. Setting $x$ explicitly overrides the \lstinline!width! option. Setting $y$ explicitly overrides the \lstinline!height! option. Please note that it is \emph{not} possible to specify \lstinline!x! as argument to \lstinline!tikzpicture!. The option \begin{lstlisting} \begin{tikzpicture}[x=1.5cm] \begin{axis} ... \end{axis} \end{tikzpicture} \end{lstlisting} won't have any effect because an axis is always scale to the final size {\centering\lstinline!(\axisdefaultwidth,\axisdefaultheight)! }% \noindent (see the \lstinline!width! option). \subsubsection{\texttt{hide axis=[true$|$false]}} Allows to hide the axis. No outer rectangle, no tick marks and no labels will be drawn. Only titles and legends will be processed as usual. Axis scaling and clipping will be done as if you did not use \texttt{hide axis}. \subsubsection{\texttt{[xy]filter=CMD}} The option \texttt{xfilter} and \texttt{yfilter} allow coordinate filtering. A coordinate filter maps an input coordinate to an output coordinate (or discards it completely). Coordinate filters are useful in automatic processing system, where \PGFPlots\ is used to display automatically generated plots. You may not want to filter your coordinates by hand, so these options provide a tool to do this automatically. Be warned: `\texttt{xfilter}' and `\texttt{yfilter}' are advanced options and may require advanced knowledge about \TeX. They are used as in the following example. The code \begin{lstlisting} \def\myOwnXfilter#1\to#2{% \def#2{0.5}% }% \begin{tikzpicture} \begin{axis}[xfilter={\myOwnXfilter}] \addplot plot coordinates { (4,0) (6,1) }; \end{axis} \end{tikzpicture} \end{lstlisting} will result in \begin{center} {% \def\myOwnXfilter#1\to#2{% \def#2{0.5}% }% \begin{tikzpicture} \begin{axis}[xfilter={\myOwnXfilter}] \addplot plot coordinates { (4,0) (6,1) }; \end{axis} \end{tikzpicture} }% \end{center} because all $x$-coordinates are replaced by~$0.5$. The Argument `\texttt{CMD}' is the name of a \TeX-macro which takes exactly two arguments which are separated by the string `\texttt{\string\to}'. Such a macro is defined as \begin{lstlisting} \def\exampleFilter#1\to#2{% \def#2{#1}% }% \end{lstlisting} This example uses the \TeX-command \lstinline!\def! to define variables and commands. The arguments are used as follows: \begin{itemize} \item \PGFPlots\ invokes the filter with argument \texttt{\#1} set to the input coordinate. For $x$-filters, this is the $x$-coordinate as it is specified to \lstinline!\addplot!, for $y$-filters it is the $y$-coordinate. \item If the corresponding axis is logarithmic, \texttt{\#1} is the \emph{logarithm} of the coordinate as a real number, for example \texttt{\#1=4.2341}. \item The arguments to coordinate filters are not transformed. You may need to call coordinate parsing routines. \item Argument \texttt{\#2} is the name of a \TeX\ command. The filter should assign this command. The first filter above assigned the constant~$0.5$ and the second filter did not filter anything because it is the identity. The replacement text of \texttt{\#2} is expected to be \emph{either} empty \emph{or} a real number (without any length-suffix like `cm' or `pt'). If it is empty, the coordinate won't be drawn at all, it will be thrown away. \end{itemize} \subsection{\texttt{execute at begin plot=COMMANDS}} This axis option allows to invoke `\texttt{COMMANDS}' at the beginning of each \lstinline!\addplot! command. The argument `\texttt{COMMANDS}' can be any \LaTeX\ content. You may use this in conjunction with \texttt{xfilter=...} to reset any counters or whatever. An example would be to change every 4th coordinate. \subsection{\texttt{execute at end plot=COMMANDS}} This axis option allows to invoke `\texttt{COMMANDS}' after each \lstinline!\addplot! command. The argument `\texttt{COMMANDS}' can be any \LaTeX\ content.