summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/pgfplots/pgfplots.reference.tex
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/doc/latex/pgfplots/pgfplots.reference.tex')
-rw-r--r--Master/texmf-dist/doc/latex/pgfplots/pgfplots.reference.tex1659
1 files changed, 1300 insertions, 359 deletions
diff --git a/Master/texmf-dist/doc/latex/pgfplots/pgfplots.reference.tex b/Master/texmf-dist/doc/latex/pgfplots/pgfplots.reference.tex
index e2dd98148f5..40049e9d851 100644
--- a/Master/texmf-dist/doc/latex/pgfplots/pgfplots.reference.tex
+++ b/Master/texmf-dist/doc/latex/pgfplots/pgfplots.reference.tex
@@ -3,7 +3,7 @@
\section{Command Reference}
\subsection{The Axis-environments}
There is an axis environment for linear scaling, two for semi-logarithmic scaling and one for double-logarithmic scaling.
-\begin{environment}{{axis}\marg{options}}
+\begin{environment}{{axis}\oarg{options}}
The axis environment for normal plots with linear axis scaling.
The `|every linear axis|' style key can be modified with
@@ -13,7 +13,7 @@ There is an axis environment for linear scaling, two for semi-logarithmic scalin
to install styles specifically for linear axes. These styles can contain both \Tikz- and \PGFPlots\ options.
\end{environment}
-\begin{environment}{{semilogxaxis}\marg{options}}
+\begin{environment}{{semilogxaxis}\oarg{options}}
The axis environment for logarithmic scaling of~$x$ and normal scaling of~$y$.
Use
\begin{codeexample}[code only]
@@ -22,13 +22,13 @@ Use
to install styles specifically for the case with |xmode=log|, |ymode=normal|.
\end{environment}
-\begin{environment}{{semilogyaxis}\marg{options}}
+\begin{environment}{{semilogyaxis}\oarg{options}}
The axis environment for normal scaling of~$x$ and logarithmic scaling of~$y$,
The style `|every semilogy axis|' will be installed for each such plot.
\end{environment}
-\begin{environment}{{loglogaxis}\marg{options}}
+\begin{environment}{{loglogaxis}\oarg{options}}
The axis environment for logarithmic scaling of both, $x$~and~$y$ axes,
As for the other axis possibilities, there is a style `|every loglog axis|' which is installed at the environment's beginning.
\end{environment}
@@ -83,7 +83,7 @@ coordinates
\end{tikzpicture}
\end{codeexample}
-\begin{command}{\addplot[\meta{style options}] \textcolor{gray}{plot[\meta{behavior options}]} \meta{input data} \meta{trailing path commands};}
+\begin{command}{\addplot\oarg{style options} \textcolor{gray}{plot\oarg{behavior options}} \meta{input data} \meta{trailing path commands};}
This is the main plotting command, available within each axis environment.
It reads point coordinates from one of the available input sources specified by \meta{input data}, updates limits, remembers \meta{style options} for use in a legend (if any) and applies any necessary coordinate transformations (or logarithms).
@@ -108,18 +108,18 @@ Some more details:
to modify options for the plot with number~$3$ only. The first plot has number~$0$.
\item The \meta{style options} are remembered for the legend. Furthermore, they are available as `|current plot style|' as long as the path is not yet finished or in associated error bars.
\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!.
+ \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 |\addplot|.
\begin{codeexample}[]
\begin{tikzpicture}
\begin{loglogaxis}
\addplot coordinates {
- (769, 1.6227e-04)
- (1793, 4.4425e-05)
- (4097, 1.2071e-05)
- (9217, 3.2610e-06)
- (2.2e5, 2.1E-6)
- (1e6, 0.00003341)
- (2.3e7, 0.00131415)
+ (769, 1.6227e-04)
+ (1793, 4.4425e-05)
+ (4097, 1.2071e-05)
+ (9217, 3.2610e-06)
+ (2.2e5, 2.1E-6)
+ (1e6, 0.00003341)
+ (2.3e7, 0.00131415)
};
\end{loglogaxis}
\end{tikzpicture}
@@ -132,18 +132,18 @@ Some 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.
+ \item If you did not specify axis limits for $x$ and $y$ manually, |\addplot| will compute them automatically.
The automatic computation of axis limits works as follows:
\begin{enumerate}
\item Every coordinate will be checked. Care has been taken to avoid \TeX's limited numerical capabilities.
- \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}!.
+ \item Since more than one |\addplot| command may be used inside an |\begin{axis}...\end{axis}|, all drawing commands will be postponed until |\end{axis}|.
\end{enumerate}
\end{itemize}
\end{command}
\subsubsection{Providing Input Coordinates}
-\begin{addplotoperation}[noindex]{coordinates}{\marg{coordinate list}}
+\begin{addplotoperation}[]{coordinates}{\marg{coordinate list}}
The `|plot coordinates|' command is provided by \Tikz\ and reads its input data from a sequence of point coordinates.
\begin{codeexample}[code only]
\addplot plot coordinates {
@@ -153,7 +153,7 @@ The `|plot coordinates|' command is provided by \Tikz\ and reads its input data
};
\end{codeexample}
-You can also supply error coordinates (reliability bounds) if you are interested in error bars. Simply append the error coordinates with `|+- (|\marg{ex}|,|\marg{ey}|)|' to the associated coordinate:
+You can also supply error coordinates (reliability bounds) if you are interested in error bars. Simply append the error coordinates with `|+- |\parg{ex,ey}' to the associated coordinate:
\begin{codeexample}[code only]
\addplot plot coordinates {
(0,0) +- (0.1,0)
@@ -176,12 +176,12 @@ The coordinates as such can be numbers as |+5|, |-1.2345e3|, |35.0e2|, |0.000001
\end{addplotoperation}
-\begin{addplotoperation}[noindex]{file}{\marg{name}}
+\begin{addplotoperation}[]{file}{\marg{name}}
\PGFPlots\ supports two ways to read plot coordinates of external files, and one of them is the \Tikz-command `|plot file|'. It is to be used like
\begin{codeexample}[code only]
\addplot plot file {datafile.dat};
\end{codeexample}
-where \marg{name} is a text file with at least two columns which will be used as $x$ and $y$ coordinates. Such files are often generated by \textsc{gnuplot}:
+where \marg{name} is a text file with at least two columns which will be used as $x$ and $y$ coordinates. Lines starting with `|%|' or `|#|' are ignored. Such files are often generated by \textsc{gnuplot}:
\begin{codeexample}[code only]
#Curve 0, 20 points
#x y type
@@ -193,10 +193,25 @@ where \marg{name} is a text file with at least two columns which will be used as
9.47368 -0.04889 i
10.00000 -0.54402 i
\end{codeexample}
-This listing has been copied from~\cite[section~16.4]{tikz}. The mentioned section also contains some more details about using |plot file|.
+This listing has been copied from~\cite[section~16.4]{tikz}.
+
+Plot file accepts one optional argument,
+
+\begin{codeexample}[code only]
+\addplot file[skip first] {datafile.dat};
+\end{codeexample}
+
+\noindent
+which allows to skip over a non-comment header line. This allows to read the same input files as |plot table| by skipping over column names. Please note that comment lines do not count as lines here.
+
+Plot file is very similar to |plot table|: you can achieve the same effect with
+\begin{codeexample}[code only]
+\addplot table[x index=0,y index=0,header=false] {datafile.dat};
+\end{codeexample}
+\noindent Due to its simplicity, |plot file| is slightly faster while |plot table| allows higher flexibility.
\end{addplotoperation}
-\begin{addplotoperation}[noindex]{table}{[\meta{column selection}]\marg{file}}
+\begin{addplotoperation}[]{table}{\oarg{column selection}\marg{file}}
\PGFPlots\ comes with a new plotting command, the `|plot table|' macro. It's usage is similar in spirit to `|plot file|', but its flexibility is higher. Given a data file like
\begin{codeexample}[code only]
dof L2 Lmax maxlevel
@@ -239,7 +254,11 @@ Alternatively, you can load the table \emph{once} and use it \emph{multiple} tim
\addplot table[x=dof,y=Lmax] from \table;
...
\end{codeexample}
-I am not really sure how much time can be saved, but it works anyway.
+I am not really sure how much time can be saved, but it works anyway. As a rule of thumb, decide as follows:
+\begin{enumerate}
+ \item If tables contain few rows and many columns, the |from |\meta{\textbackslash macro} framework will be more efficient.
+ \item If tables contain more than~$200$ data points (rows), you should always use file input (and reload if necessary).
+\end{enumerate}
If you do prefer to access columns by column indices instead of column names (or your tables do not have column names), you can also use
\begin{codeexample}[code only]
@@ -276,7 +295,26 @@ Summary and remarks:
\end{itemize}
\end{addplotoperation}
-\begin{addplotoperation}[noindex]{function}{\marg{gnuplot code}}
+\begin{pgfplotskey}{table/header=\mchoice{true,false} (initially true)}
+ Allows to disable header identification for |plot table|. See above.
+\end{pgfplotskey}
+\begin{pgfplotsxykeylist}{table/\x=\marg{column name},
+ table/\x\ index=\marg{column index}}
+ These keys define the sources for |plot table|. If both, column names and column indices are given, column names are preferred. Column indexing starts with~$0$. The initial setting is to use |x index=0| and |y index=1|.
+
+ Please note that column \emph{aliases} will be considered if unknown column names are used. Please refer to the manual of \PGFPlotstable\ which comes with this package.
+\end{pgfplotsxykeylist}
+\begin{pgfplotsxykeylist}{%
+ \x\ error=\marg{column name},
+ \x\ error index=\marg{column index}}
+ These keys define input sources for error bars with explicit error values. Please see section~\ref{sec:errorbars} for details.
+\end{pgfplotsxykeylist}
+\begin{key}{/pgfplots/table/col sep=\mchoice{space,comma,semicolon,colon,braces} (initially space)}
+ Allows to choose column separators for |plot table|. Please refer to the manual of \PGFPlotstable\ which comes with this package for details about |col sep|.
+\end{key}
+
+
+\begin{addplotoperation}[]{function}{\marg{gnuplot code}}
The plot function command uses the external program |gnuplot| to compute coordinates. The resulting coordinates are written to a text file which will be plotted with |plot file|. \PGF\ checks whether coordinates need to be re-generated and calls |gnuplot| whenever necessary (this is usually the case if you change the number of samples, the argument to |plot function| or the plotted domain\footnote{Please note that \PGFPlots\ produces slightly different files than \Tikz\ when used with |plot function| (it configures high precision output). You should use different ids to avoid conflicts in such a case.}).
Since system calls are a potential danger, they need to be enabled explicitly using command line options, for example
@@ -305,7 +343,7 @@ Sometimes it is called |shell-escape| or |enable-write18|.
The \meta{style options} determine the appearance of the plotted function; these parameters also affect the legend. The \meta{behavior options} are specific to the gnuplot interface. These options are described in all detail in \cite[section~18.6]{tikz}. A short summary is shown below.
\end{addplotoperation}
-\begin{key}{/tikz/domain=[\meta{start}:\meta{end}] (initially [-5:5])}
+\begin{key}{/tikz/domain=\meta{start}:\meta{end} (initially [-5:5])}
Determines the plotted range. This is not necessarily the same as the axis limits (which are configured with the |xmin|/|xmax| options).
This option is also used for plot expression, see below.
@@ -330,7 +368,7 @@ The \meta{style options} determine the appearance of the plotted function; these
\noindent
Please refer to \cite[section~18.6]{tikz} for more details about |plot function| and the |gnuplot| interaction.
-\begin{addplotoperation}[noindex]{(\meta{$x$ expression},\meta{$y$ expression})}{}
+\begin{addplotoperation}[]{(\meta{$x$ expression},\meta{$y$ expression})}{}
Similar to |plot function|, this input method allows to provide expressions which will be sampled. But unlike |plot function|, the expressions are evaluated using the math parser of \PGF, no external program is required.
\begin{codeexample}[]
\begin{tikzpicture}
@@ -363,8 +401,8 @@ the braces are necessary to delimit the $y$ argument here. If you want to use ra
to convert the radians to degrees. The \Tikz\ plot expression parser also accepts some more options like |samples at=|\marg{coordinate list} or |variable=\t| which are described in the \Tikz\ manual.
\end{addplotoperation}
-\begin{command}{\addplot+[\meta{style options}] \textcolor{gray}{\dots};}
-Does the same like |\addplot[|\meta{style options}|] ...;| except that \meta{style options} is \emph{appended} to the arguments which would have been taken for \lstinline!\addplot ...! (the element of the default list).
+\begin{command}{\addplot+\oarg{style options} \textcolor{gray}{\dots};}
+Does the same like |\addplot[|\meta{style options}|] ...;| except that \meta{style options} is \emph{appended} to the arguments which would have been taken for |\addplot ...| (the element of the default list).
\begin{codeexample}[]
\begin{tikzpicture}
@@ -460,6 +498,7 @@ It can be used to draw any \Tikz-graphics at axis coordinates. It is used like
\end{predefinednode}
\subsection{Legend Commands}
+\label{pgfplots:sec:legendcmds}
\begin{command}{\addlegendentry\marg{name}}
Adds a single legend entry to the legend list. This will also enable legend drawing.
@@ -487,7 +526,9 @@ Adds a single legend entry to the legend list. This will also enable legend draw
It does not matter where |\addlegendentry| commands are placed, only the sequence matters. You will need one |\addlegendentry| for every |\addplot| command.
-Optional argument are accepted with|\addlegendentry|[\meta{key-value-list}]|{...}|. This does mainly affect some keys affecting the legend layout, support is very limited.
+Optional argument are accepted with|\addlegendentry|\oarg{key-value-list}|{...}|. This does mainly affect some keys affecting the legend layout, support is very limited.
+
+Using |\addlegendentry| disables the key |legend entries|.
\end{command}
@@ -500,120 +541,70 @@ You can use |\legend|\marg{list} to assign a complete legend.
\end{codeexample}
The argument of |\legend| is a comma--separated list of entries, one for each plot. It is processed using the \PGF-foreach command\footnote{Older versions of \PGFPlots\ used \texttt{\textbackslash legend\{first\textbackslash\textbackslash second\textbackslash\textbackslash third\textbackslash\textbackslash\}} instead of comma--separated lists. This syntax is still accepted.}.
The short marker/line combination shown in legends is acquired from the \marg{style options} argument of |\addplot|.
+
+Using |\legend| overwrites any other existing legend entries.
\end{command}
\subsubsection{Legend Appearance}
-{%
-\pgfplotsset{every axis/.append style={width=3cm,scale only axis,legend style={font=\footnotesize}}}%
-\begin{stylekey}{/pgfplots/every axis legend}
-The style ``|every axis legend|'' determines the legend's position and outer appearance:
-\begin{codeexample}[code only]
-\pgfplotsset{every axis legend/.append style={
- at={(0,0)},
- anchor=south west}}
-\end{codeexample}
-will draw it at the lower left corner of the axis while
-\begin{codeexample}[code only]
-\pgfplotsset{every axis legend/.append style={
- at={(1,1)},
- anchor=north east}}
-\end{codeexample}
-means the upper right corner. The `|anchor|' option determines which point \emph{of the legend} will be placed at $(0,0)$ or $(1,1)$.
-
-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{codeexample}[code only]
-\matrix[style=every axis legend] {
- draw plot specification 1 & \node{legend 1}\\
- draw plot specification 2 & \node{legend 2}\\
- ...
-};
-\end{codeexample}
+The legend appearance can be configured with the help of several styles and options. These options are described in section~\ref{pgfplots:sec:legendopts}, under Axis Descriptions.
+\subsubsection{\texttt{\textbackslash label} and \texttt{\textbackslash ref} for Legend Creation}
+\PGFPlots\ offers a |\label| and |\ref| feature for \LaTeX\ to assemble a legend manually, for example as part of the figure caption. These references work as usual \LaTeX\ references: a |\label| remembers where and what needs to be referenced and a |\ref| expands to proper text. In context of plots, a |\label| remembers the plot specification of one plot and a |\ref| expands to the small image which would also be used inside of legends.
\begin{codeexample}[]
-\pgfplotsset{every axis legend/.append style={
- at={(1.02,1)},
- anchor=north west}}
-\begin{tikzpicture}
+\begin{tikzpicture}[baseline]
\begin{axis}
-\addplot coordinates {(0,0) (1,1)};
-\addplot coordinates {(0,1) (1,2)};
-\addplot coordinates {(0,2) (1,3)};
-\legend{$l_1$,$l_2$,$l_3$}
+ \addplot+[only marks]
+ plot[samples=15,
+ error bars/y dir=both,
+ error bars/y fixed=2.5]
+ (\x,3*\x+2.5*rand);
+ \label{pgfplots:label1}
+
+ \addplot+[mark=none] (\x,3*\x);
+ \label{pgfplots:label2}
+
+ \addplot (\x,{4*cos(\x r)});
+ \label{pgfplots:label3}
\end{axis}
\end{tikzpicture}
\end{codeexample}
-
-Use |legend columns=|\marg{number} to configure the number of horizontal legend entries.
-\begin{codeexample}[]
-\begin{tikzpicture}
-\pgfplotsset{every axis legend/.append style={
- at={(0.5,1.03)},
- anchor=south}}
-\begin{axis}[legend columns=4]
-\addplot coordinates {(0,0) (1,1)};
-\addplot coordinates {(0,1) (1,2)};
-\addplot coordinates {(0,2) (1,3)};
-\legend{$l_1$,$l_2$,$l_3$}
-\end{axis}
-\end{tikzpicture}
+\begin{codeexample}[code only]
+The picture shows the estimations \ref{pgfplots:label1} which are subjected to noise.
+It appears the model \ref{pgfplots:label2} fits the data appropriately.
+Finally, \ref{pgfplots:label3} is only here to get three examples.
\end{codeexample}
-\noindent
-Instead of the |.append style|, you can also use |legend style| as in the following example. It has the same effect.
+\noindent The picture shows the estimations \ref{pgfplots:label1} which are subjected to noise.
+It appears the model \ref{pgfplots:label2} fits the data appropriately.
+Finally, \ref{pgfplots:label3} is only here to get three examples.
+\begin{command}{\label\marg{label name}}
+ When used after |\addplot|, this command creates a \LaTeX\ label named \marg{label name}\footnote{This feature is \emph{only} available in \LaTeX, sorry.}. If this label is cross-referenced with |\ref|\marg{label name} somewhere, the associated plot specification will be inserted.
\begin{codeexample}[]
-\begin{tikzpicture}
-\begin{axis}[
- legend style={
- at={(1,0.5)},
- anchor=east}]
-\addplot coordinates {(0,0) (1,1)};
-\addplot coordinates {(0,1) (1,2)};
-\addplot coordinates {(0,2) (1,3)};
-\legend{$l_1$,$l_2$,$l_3$}
-\end{axis}
-\end{tikzpicture}
+Label3 = \ref{pgfplots:label3};
+Label2 = \ref{pgfplots:label2}
\end{codeexample}
+ The label is assembled using |legend image code| and the plot style of the last plot. Any \PGFPlots\ option is expanded until only \Tikz\ (or \pgfname) options remain; these options are used to get an independant label\footnote{Please note that you can't use the label/ref mechanism in conjunction with image externalization as this will (naturally) lead to undefined references.}.
-\noindent
-The default |every axis legend| style is
+ More precisely, the small image generated by |\ref|\marg{label name} is
\begin{codeexample}[code only]
-\pgfplotsset{every axis legend/.style={%
- 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)}
-}}
+\tikz[/pgfplots/every crossref picture] {...}
\end{codeexample}
-\paragraph{Attention:} you should \emph{not reset} the default style to stay compatible with future versions. If possible, use
-\begin{codeexample}[code only]
-\pgfplotsset{every axis legend/.append style={...}}
-\end{codeexample}
-\end{stylekey}
-
-}
-
-
-\begin{command}{\autoplotspeclist}
-This command should no longer be used, although it will be kept as technical implementation detail. Please use the `|cycle list|' option, section~\ref{sec:cycle:list}.
+ \noindent where the contents is determined by |legend image code| and the plot style.
\end{command}
-\begin{command}{\pgfmathlogtologten\meta{number}}
-Assigns the result of $\meta{number}/\log(10)$ to \lstinline!\pgfmathresult!.
-\end{command}
+\begin{command}{\ref\marg{label name}}
+ Can be used to reference a labeled, single plot. See the example above.
-\begin{command}{\logten}
-Expands to the constant $\log(10)$. Useful for logplots because $\log(10^i) = i\log(10)$. This command is only available inside of an \Tikz-picture.
+ This will also work together with |hyperref| links and |\pageref|.
\end{command}
-\begin{command}{\pgfmathprintnumber\marg{number}}
-Generates pretty--printed output\footnote{This method was previously \texttt{\textbackslash prettyprintnumber}. It's functionality has been included into \PGF\ and the old command is now deprecated.} for \marg{number}. This method is used for every tick label.
+\begin{stylekey}{/pgfplots/every crossref picture}
+ A style which will be used by the cross-referencing feature for plots. The default is
+\begin{codeexample}[code only]
+\pgfplotsset{every crossref picture/.style={baseline,yshift=0.3em}
+\end{codeexample}
+\end{stylekey}
-The number is printed using the current number printing options, see section~\ref{sec:number:printing} for the different number styles, rounding precision and rounding methods.
-\end{command}
\subsection{Closing Plots}
\begin{command}{\closedcycle}
@@ -636,7 +627,7 @@ The number is printed using the current number printing options, see section~\re
\end{axis}
\end{tikzpicture}
\end{codeexample}
- In case of stacked plots, |\closedcycle| connects the current plot with the previous plot instead of connecting with the $x$~axis\footnote{The implementation for stacked plots requires some additional logic to determine the filled area: \lstinline{\\closedcycle} will produce a \lstinline!plot coordinates! command with \emph{reversed} coordinates of the previous plot. This is usually irrelevant for end users, but it assumes that the plot's type is symmetric. Since constant plots are inherently unsymmetric, \lstinline{\\closedcycle} will use \texttt{const plot mark right} as reversed sequence for \texttt{const plot mark left}.}.
+ In case of stacked plots, |\closedcycle| connects the current plot with the previous plot instead of connecting with the $x$~axis\footnote{The implementation for stacked plots requires some additional logic to determine the filled area: \lstinline{\\closedcycle} will produce a |plot coordinates| command with \emph{reversed} coordinates of the previous plot. This is usually irrelevant for end users, but it assumes that the plot's type is symmetric. Since constant plots are inherently unsymmetric, \lstinline{\\closedcycle} will use \texttt{const plot mark right} as reversed sequence for \texttt{const plot mark left}.}.
\begin{codeexample}[]
\begin{tikzpicture}
\begin{axis}[stack plots=y]
@@ -650,6 +641,24 @@ The number is printed using the current number printing options, see section~\re
\end{command}
\subsection{Other Commands}
+\begin{command}{\autoplotspeclist}
+This command should no longer be used, although it will be kept as technical implementation detail. Please use the `|cycle list|' option, section~\ref{sec:cycle:list}.
+\end{command}
+
+\begin{command}{\pgfmathlogtologten\meta{number}}
+Assigns the result of $\meta{number}/\log(10)$ to |\pgfmathresult|.
+\end{command}
+
+\begin{command}{\logten}
+Expands to the constant $\log(10)$. Useful for logplots because $\log(10^i) = i\log(10)$. This command is only available inside of an \Tikz-picture.
+\end{command}
+
+\begin{command}{\pgfmathprintnumber\marg{number}}
+Generates pretty--printed output\footnote{This method was previously \texttt{\textbackslash prettyprintnumber}. It's functionality has been included into \PGF\ and the old command is now deprecated.} for \marg{number}. This method is used for every tick label.
+
+The number is printed using the current number printing options, see section~\ref{sec:number:printing} for the different number styles, rounding precision and rounding methods.
+\end{command}
+
\begin{command}{\plotnum}
Inside of |\addplot| or any associated style, option or command, |\plotnum| expands to the current plot's number, starting with~$0$.
\end{command}
@@ -1163,7 +1172,8 @@ Area plots are a combination of |\closedcycle| and |stack plots|. They can be co
\begin{tikzpicture}
\begin{axis}[
stack plots=y,
- area cycle list]
+ area style,
+ enlarge x limits=false]
\addplot coordinates
{(0,1) (1,1) (2,2) (3,2)}
\closedcycle;
@@ -1176,13 +1186,28 @@ Area plots are a combination of |\closedcycle| and |stack plots|. They can be co
\end{axis}
\end{tikzpicture}
\end{codeexample}
+\noindent
+Area plots may need modified legends, for example using the |area legend| key. Furthermore, one may want to consider the |axis on top| key such that filled areas to not overlap ticks and grid lines.
+
+\begin{stylekey}{/pgfplots/area style}
+ A style which sets
+\begin{codeexample}[code only]
+\pgfplotsset{
+ /pgfplots/area style/.style={%
+ area cycle list,
+ area legend,
+ axis on top,
+ }}
+\end{codeexample}
+\end{stylekey}
\begin{codeexample}[]
\begin{tikzpicture}
\begin{axis}[
const plot,
stack plots=y,
- area cycle list]
+ area style,
+ enlarge x limits=false]
\addplot coordinates
{(0,1) (1,1) (2,2) (3,2)}
\closedcycle;
@@ -1201,7 +1226,8 @@ Area plots are a combination of |\closedcycle| and |stack plots|. They can be co
\begin{axis}[
smooth,
stack plots=y,
- area cycle list]
+ area style,
+ enlarge x limits=false]
\addplot coordinates
{(0,1) (1,1) (2,2) (3,2)}
\closedcycle;
@@ -1226,14 +1252,15 @@ Area plots are a combination of |\closedcycle| and |stack plots|. They can be co
\begin{tikzpicture}
\begin{axis}[
- ymin=0,ymax=210,
+ ymin=0,
minor tick num=4,
- enlargelimits=false,
- tick align=outside,
+ enlarge x limits=false,
+ axis on top,
every axis plot post/.append style=
{mark=none},
const plot,
legend style={
+ area legend,
at={(0.5,-0.15)},
anchor=north,
legend columns=-1}]
@@ -1255,20 +1282,21 @@ Area plots are a combination of |\closedcycle| and |stack plots|. They can be co
\begin{tikzpicture}
\begin{axis}[
- ymin=0,ymax=160,
+ ymin=0,
minor tick num=4,
- enlargelimits=false,
- tick align=outside,
+ enlarge x limits=false,
const plot,
+ axis on top,
stack plots=y,
cycle list={%
{blue!70!black,fill=blue},%
- {green,fill=green!50!black},%
- {green!30!white,fill=green!80!white},%
+ {blue!60!white,fill=blue!30!white},%
+ {draw=none,fill={rgb:red,138;green,82;blue,232}},%
{red,thick}%
},
ylabel={Mem [GB]},
legend style={
+ area legend,
at={(0.5,-0.15)},
anchor=north,
legend columns=2}]
@@ -1276,7 +1304,7 @@ Area plots are a combination of |\closedcycle| and |stack plots|. They can be co
\addplot table[x=time,y=memused] from \table \closedcycle;
\addplot table[x=time,y=memcached] from \table \closedcycle;
\addplot table[x=time,y=membuf] from \table \closedcycle;
- \addplot plot[/pgfplots/stack plots=false]
+ \addplot plot[stack plots=false]
table[x=time,y=memtotal] from \table;
\legend{Memory used,Memory cached,Memory buffered,Total memory}
\end{axis}
@@ -1313,7 +1341,7 @@ This list is copied from~\cite[section~29]{tikz}:
\item[mark=+] \showit{mark=+}
% \item[mark=ball] \showit{mark=ball}
\end{longdescription}
-And with \lstinline!\usetikzlibrary{plotmarks}!:
+And with |\usetikzlibrary{plotmarks}|:
\begin{longdescription}
\item[mark=$-$] \showit{mark=-}
\item[mark=$\vert$] \showit{mark=|}
@@ -1344,6 +1372,54 @@ All these options have been drawn with the additional options
]
\end{codeexample}
+\begin{key}{/tikz/mark size=\marg{dimension}}
+ This \Tikz\ option allows to set marker sizes to \marg{dimension}. For circular markers, \marg{dimension} is the radius, for other plot marks it is about half the width and height.
+\end{key}
+\begin{key}{/tikz/every mark}
+ This \Tikz\ style can be reconfigured to set marker appearance options like colors or transformations like scaling or rotation. \PGFPlots\ appends its cycle list options to this style.
+\begin{codeexample}[]
+\begin{tikzpicture}
+\begin{axis}[y=2cm]
+ \addplot coordinates
+ {(-2,0) (-1,1) (0,0) (1,1) (2,0)};
+\end{axis}
+\end{tikzpicture}
+\end{codeexample}
+
+\begin{codeexample}[]
+\tikzset{every mark/.append style={scale=2}}
+\begin{tikzpicture}
+\begin{axis}[y=2cm]
+ \addplot coordinates
+ {(-2,0) (-1,1) (0,0) (1,1) (2,0)};
+\end{axis}
+\end{tikzpicture}
+\end{codeexample}
+
+The |every axis plot post| style can be used to overwrite parts (or all) of the drawing styles which are assigned for plots.
+\begin{codeexample}[]
+% Overwrite any cycle list:
+\pgfplotsset{
+ every axis plot post/.append style={
+ mark=triangle,
+ every mark/.append style={rotate=90}}}
+\begin{tikzpicture}
+\begin{axis}[y=2cm]
+ \addplot coordinates
+ {(-2,0) (-1,1) (0,0) (1,1) (2,0)};
+\end{axis}
+\end{tikzpicture}
+\end{codeexample}
+\end{key}
+
+\begin{key}{/tikz/mark options=\marg{options}}
+ Resets |every mark| to \marg{options}.
+\end{key}
+
+Markers paths are not subjected to clipping as other parts of the figure. Markers are either drawn completely or not at all.
+
+\Tikz\ offers more options for marker fine tuning, please refer to~\cite{tikz} for details.
+
\subsubsection{Line Styles}
\def\showit#1{%
\tikz\draw[%
@@ -1380,7 +1456,7 @@ The following line styles are predefined in \Tikz.
\begin{stylekey}{/tikz/loosely dashed}
\showit{style=loosely dashed}
\end{stylekey}
-You may need the option \lstinline!mark options={solid}! to avoid dotted or dashed marker boundaries.
+You may need the option |mark options={solid}| to avoid dotted or dashed marker boundaries.
\endgroup
\subsubsection{Font Size and Line Width}
@@ -1455,11 +1531,77 @@ This example shows the same plots as on page~\pageref{page:plotcoords:src} (usin
\end{tikzpicture}
\end{codeexample}
+\subsubsection{Colors}
+{%
+\def\showcolorandname#1{%
+ \showcolor{#1}~#1%
+}%
+\def\showcolor#1{%
+ \tikz \draw[black,fill={#1}] (0,0) rectangle (1em,0.6em);%
+}%
+\PGF\ uses the color support of |xcolor|. Therefore, the main reference for how to specify colors is the |xcolor| manual~\cite{xcolor}. The \PGF\ manual~\cite{tikz} is the reference for how to select colors for specific purposes like drawing, filling, shading, patterns etc. This section contains a short overview over the specification of colors in~\cite{xcolor} (which is not limited to \PGFPlots).
+
+The package |xcolor| defines a set of predefined colors, namely
+\showcolorandname{red},
+\showcolorandname{green},
+\showcolorandname{blue},
+\showcolorandname{cyan},
+\showcolorandname{magenta},
+\showcolorandname{yellow},
+\showcolorandname{black},
+\showcolorandname{gray},
+\showcolorandname{white},
+\showcolorandname{darkgray},
+\showcolorandname{lightgray},
+\showcolorandname{brown},
+\showcolorandname{lime},
+\showcolorandname{olive},
+\showcolorandname{orange},
+\showcolorandname{pink},
+\showcolorandname{purple},
+\showcolorandname{teal},
+\showcolorandname{violet}.
+
+\begin{codeexample}[]
+\begin{tikzpicture}
+ \begin{axis}[enlarge x limits=false]
+ \addplot[red]
+ plot[samples=500] (\x,{sin(\x r)});
+
+ \addplot[orange]
+ plot[samples=7] (\x,{sin(\x r)});
+
+ \addplot[teal,const plot]
+ plot[samples=14] (\x,{sin(\x r)});
+ \end{axis}
+\end{tikzpicture}
+\end{codeexample}
+
+Besides predefined colors, you can \emph{mix} two (or more) colors. For example, \showcolorandname{red!30!white} contains $30\%$ of \showcolorandname{red} and $70\%$ of \showcolorandname{white}. Consequently, one can build \showcolorandname{red!70!white} to get $70\%$ red and $30\%$ white or \showcolorandname{red!10!white} for $10\%$ red and $90\%$ white. This mixing can be done with any color, \showcolorandname{red!50!green}, \showcolorandname{blue!50!yellow}.
+
+A different type of color mixing is supported, which allows to take $100\%$ of \emph{each} component. For example, \showcolorandname{rgb,2:red,1;green,1} will add $1/2$ part \showcolorandname{red} and $1/2$ part \showcolorandname{green} and we reproduced the example from above. Using the denominator~$1$ instead of~$2$ leads to \showcolorandname{rgb,1:red,1;green,1} which uses $1$ part \showcolorandname{red} and $1$ part \showcolorandname{green}. Many programs allow to select pieces between $0,\dotsc,255$, so a denominator of $255$ is useful. Consequently, \showcolorandname{rgb,255:red,231;green,84;blue,121} uses $231/255$ red, $84/255$ green and $121/255$. This corresponds to the standard RGB color $(231,84,121)$. Other examples are \showcolorandname{rgb,255:red,32;green,127;blue,43}, \showcolorandname{rgb,255:red,178;green,127;blue,43}, \showcolorandname{rgb,255:red,169;green,178;blue,43}.
+
+It is also possible to use RGB values, the HSV color model or the HTML color syntax directly. However, this requires some more programming. I suppose this is the fastest (and probably the most uncomfortable) method to use colors. For example,
+\begin{codeexample}[]
+\definecolor{color1}{rgb}{1,1,0}
+\tikz \fill[color1]
+ (0,0) rectangle (1em,0.6em);
+\end{codeexample}
+\noindent creates the color with $100\%$ red, $100\%$ green and $0\%$ blue;
+
+\begin{codeexample}[]
+\definecolor{color1}{HTML}{D0B22B}
+\tikz \fill[color1]
+ (0,0) rectangle (1em,0.6em);
+\end{codeexample}
+\noindent creates the color with $208/255$ pieces red, $178/255$ pieces green and $43$ pieces blue, specified in standard HTML notation. Please refer to the |xcolor| manual~\cite{xcolor} for more details and color models.
+}%
+
\subsubsection{Options Controlling Linestyles}
\label{sec:cycle:list}%
\begin{pgfplotskeylist}{cycle list=\marg{list},cycle list name=\marg{\textbackslash macro}}
-Allows to specify a list of plot specifications which will be used for each \hbox{\lstinline!\addplot!}-command without explicit plot specification.
+Allows to specify a list of plot specifications which will be used for each \hbox{|\addplot|}-command without explicit plot specification.
There are several possiblities to change it:
\begin{enumerate}
@@ -1500,7 +1642,7 @@ These examples employs the same coords as in the example on page~\pageref{page:p
\end{loglogaxis}
\end{tikzpicture}
\end{codeexample}
- (This example list requires \lstinline!\usetikzlibrary{plotmarks}!).
+ (This example list requires |\usetikzlibrary{plotmarks}|).
\item Define macro names and use them with `|cycle list name|':
\begin{codeexample}[code only]
\pgfcreateplotcyclelist{\mylist}{%
@@ -1517,7 +1659,7 @@ These examples employs the same coords as in the example on page~\pageref{page:p
\end{codeexample}
\end{enumerate}
-\paragraph{Remark:} You can also terminate single entries with `\lstinline!\\!' as in
+\paragraph{Remark:} You can also terminate single entries with `|\\|' as in
\begin{codeexample}[code only]
\begin{axis}[cycle list={%
blue,mark=*\\%
@@ -1531,18 +1673,21 @@ These examples employs the same coords as in the example on page~\pageref{page:p
...
\end{axis}
\end{codeexample}
-In this case, the \emph{last} entry also needs a terminating `\lstinline!\\!', but you can omit braces around the single entries.
+In this case, the \emph{last} entry also needs a terminating `|\\|', but you can omit braces around the single entries.
\end{pgfplotskeylist}
\subsection{Axis Descriptions}
+Axis descriptions are labels for $x$ and $y$ axis and titles. Axis descriptions are drawn after the plot is finished and they are not subjected to clipping. Their placement is always relative to the axis rectangle, where $(0,0)$ refers to the lower left corner and $(1,1)$ refers to the upper right one.
+
+Furthermore, axis descriptions can be placed using the predefined node |current axis|. At the time when axis descriptions are drawn, all anchors which refer to the axis origin (that means the ``real'' point $(0,0)$) or any of the axis corners can be references using |current axis.|\meta{anchor name}. Please see section~\ref{pgfplots:sec:align}, Alignment, for further details.
\subsubsection{Labels}
\begin{pgfplotsxykey}{\x label=\marg{text}}
-The options |xlabel| and |ylabel| change axis labels to \marg{text} which is any \TeX\ text. Use |xlabel={, = characters}| if you need to include `|=|' or `|,|' literally.
+The options |xlabel| and |ylabel| change axis labels to \marg{text} which is any \TeX\ text. Use ``|xlabel={, = characters}|'' if you need to include `|=|' or `|,|' literally.
Labels are \Tikz-Nodes which are placed with
\begin{codeexample}[code only]
@@ -1553,7 +1698,7 @@ Labels are \Tikz-Nodes which are placed with
[style=every axis label,
style=every axis y label]
\end{codeexample}
-so their position and appearance can be customized. As for legends, the coordinate \lstinline!(0,0)! denotes the lower left axis corner and \lstinline!(1,1)! the upper right.
+so their position and appearance can be customized. The coordinate |(0,0)| denotes the lower left axis corner and |(1,1)| the upper right.
The default styles are
\begin{codeexample}[code only]
@@ -1567,12 +1712,13 @@ The default styles are
xshift=-35pt,
rotate=90}}
\end{codeexample}
-Please add options using |.append style| instead of overwriting the default styles to ensure compatibility with future versions.
+Whenever possible, you should use |.append style| instead of overwriting the default styles to ensure compatibility with future versions.
\begin{codeexample}[code only]
\pgfplotsset{every axis label/.append style={...}}
\pgfplotsset{every axis x label/.append style={...}}
\pgfplotsset{every axis y label/.append style={...}}
\end{codeexample}
+ Use |xlabel/.add=|\marg{prefix}\marg{suffix} to modify an already assigned label.
\end{pgfplotsxykey}
\begin{pgfplotskey}{title=\marg{text}}
@@ -1623,14 +1769,152 @@ to the current axis.
% \end{loglogaxis}
% \end{tikzpicture}
%--------------------------------------------------
- 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
+The title's appearance and/or placing can be reconfigured with
\begin{codeexample}[code only]
\pgfplotsset{every axis title/.append style={at={(0.75,1)}}}
\end{codeexample}
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.
+
+Use |title/.add=|\marg{prefix}\marg{suffix} to modify an already assigned title.
\end{pgfplotskey}
+\begin{pgfplotscodekey}{extra description}
+Allows to insert \marg{commands} after axis labels, titles and legends have been typeset.
+
+As all other axis descriptions, the code can use $(0,0)$ to access the lower left corner and $(1,1)$ to access the upper right one. It won't be clipped.
+\begin{codeexample}[]
+\pgfplotsset{every axis/.append style={
+ extra description/.code={
+ \node at (0.5,0.5) {Center!};
+ }}}
+\begin{tikzpicture}
+ \begin{axis}
+ \addplot (\x,\x^2);
+ \end{axis}
+\end{tikzpicture}
+\end{codeexample}
+\end{pgfplotscodekey}
+
+
\subsubsection{Legend}
+\label{pgfplots:sec:legendopts}
+Legends can be generated in two ways: the first is to use |\addlegendentry| or |\legend| inside of an axis. This method has been presented in section~\ref{pgfplots:sec:legendcmds}, Legend Commands. The other method is to use a key.
+
+\begin{pgfplotskey}{legend entries=\marg{comma separated list}}
+ This key can be used to assign legend entries just like the commands |\addlegendentry| and |\legend|.
+\begin{codeexample}[]
+\begin{tikzpicture}
+ \begin{axis}[legend entries={$x$,$x^2$}]
+ \addplot (\x,\x);
+ \addplot (\x,\x^2);
+ \end{axis}
+\end{tikzpicture}
+\end{codeexample}
+
+ The commands for legend creation take precedence: the key is only considered if there is no legend command in the current axis. Please refer to section~\ref{pgfplots:sec:legendcmds}, Legend Commands, for details about the commands.
+\begin{codeexample}[]
+\begin{tikzpicture}
+ \begin{axis}[legend entries={$x$,$x^2$}]
+ \addplot (\x,\x);
+ \addplot (\x,\x^2);
+ \legend{$a$,$b$}% overrides the option
+ \end{axis}
+\end{tikzpicture}
+\end{codeexample}
+\end{pgfplotskey}
+
+{%
+\pgfplotsset{every axis/.append style={width=3cm,scale only axis,legend style={font=\footnotesize}}}%
+\begin{stylekey}{/pgfplots/every axis legend}
+The style ``|every axis legend|'' determines the legend's position and outer appearance:
+\begin{codeexample}[code only]
+\pgfplotsset{every axis legend/.append style={
+ at={(0,0)},
+ anchor=south west}}
+\end{codeexample}
+will draw it at the lower left corner of the axis while
+\begin{codeexample}[code only]
+\pgfplotsset{every axis legend/.append style={
+ at={(1,1)},
+ anchor=north east}}
+\end{codeexample}
+means the upper right corner. The `|anchor|' option determines which point \emph{of the legend} will be placed at $(0,0)$ or $(1,1)$.
+
+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{codeexample}[code only]
+\matrix[style=every axis legend] {
+ draw plot specification 1 & \node{legend 1}\\
+ draw plot specification 2 & \node{legend 2}\\
+ ...
+};
+\end{codeexample}
+
+\begin{codeexample}[]
+\pgfplotsset{every axis legend/.append style={
+ at={(1.02,1)},
+ anchor=north west}}
+\begin{tikzpicture}
+\begin{axis}
+\addplot coordinates {(0,0) (1,1)};
+\addplot coordinates {(0,1) (1,2)};
+\addplot coordinates {(0,2) (1,3)};
+\legend{$l_1$,$l_2$,$l_3$}
+\end{axis}
+\end{tikzpicture}
+\end{codeexample}
+
+Use |legend columns=|\marg{number} to configure the number of horizontal legend entries.
+\begin{codeexample}[]
+\begin{tikzpicture}
+\pgfplotsset{every axis legend/.append style={
+ at={(0.5,1.03)},
+ anchor=south}}
+\begin{axis}[legend columns=4]
+\addplot coordinates {(0,0) (1,1)};
+\addplot coordinates {(0,1) (1,2)};
+\addplot coordinates {(0,2) (1,3)};
+\legend{$l_1$,$l_2$,$l_3$}
+\end{axis}
+\end{tikzpicture}
+\end{codeexample}
+\noindent
+Instead of the |.append style|, you can also use |legend style| as in the following example. It has the same effect.
+
+\begin{codeexample}[]
+\begin{tikzpicture}
+\begin{axis}[
+ legend style={
+ at={(1,0.5)},
+ anchor=east}]
+\addplot coordinates {(0,0) (1,1)};
+\addplot coordinates {(0,1) (1,2)};
+\addplot coordinates {(0,2) (1,3)};
+\legend{$l_1$,$l_2$,$l_3$}
+\end{axis}
+\end{tikzpicture}
+\end{codeexample}
+
+\noindent
+The default |every axis legend| style is
+\begin{codeexample}[code only]
+\pgfplotsset{every axis legend/.style={%
+ cells={anchor=center},% Centered entries
+ 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{codeexample}
+Whenever possible, consider using |.append style| to keep the default styles active. This ensures compatibility with future versions.
+\begin{codeexample}[code only]
+\pgfplotsset{every axis legend/.append style={...}}
+\end{codeexample}
+\end{stylekey}
+
+}
\begin{pgfplotskey}{legend columns=\marg{number} (default 1)}
Allows to configure the maximum number of adjacent legend entries. The default value~|1| places legend entries vertically below each other.
@@ -1644,7 +1928,7 @@ Configures where the small line specifications will be drawn: left of the descri
\begin{pgfplotscodekey}{legend image code}
\label{opt:legend:image:code}
-Allows to replace the default images which are drawn inside of legends. The first argument to this option is the plot specification, a key-value list which has been determined by \lstinline!\addplot!.
+Allows to replace the default images which are drawn inside of legends. The first argument to this option is the plot specification, a key-value list which has been determined by |\addplot|.
The default is
\begin{codeexample}[code only]
@@ -1659,17 +1943,91 @@ The default is
\end{codeexample}
\end{pgfplotscodekey}
+\begin{stylekey}{/pgfplots/area legend}
+ A style which sets |legend image code| to
+\begin{codeexample}[code only]
+\pgfplotsset{
+ /pgfplots/legend image code/.code={%
+ \draw[#1] (0cm,-0.1cm) rectangle (0.6cm,0.1cm);
+ }}
+\end{codeexample}
+
+\begin{codeexample}[]
+\begin{tikzpicture}
+\begin{axis}[area legend,
+ axis x line=bottom,
+ axis y line=left,
+ domain=0:1,
+ legend style={at={(0.03,0.97)},
+ anchor=north west},
+ axis on top,xmin=0]
+\addplot[pattern=crosshatch dots,
+ pattern color=blue,draw=blue]
+plot[samples=500]
+ (\x,{sqrt(\x)}) \closedcycle;
+
+\addplot[pattern=crosshatch,
+ pattern color=blue!30!white,
+ draw=blue!30!white]
+ (\x,\x^2) \closedcycle;
+
+\addplot[red] coordinates {(0,0) (1,1)};
+\legend{$\sqrt x$,$x^2$,$x$}
+\end{axis}
+\end{tikzpicture}
+\end{codeexample}
+\end{stylekey}
+
\subsubsection{Axis Lines}
By default the axis lines are drawn as a |box|, but it is possible to change the appearance of the $x$~and~$y$ axis lines.
+\begin{pgfplotskeylist}{
+ axis x line=\mchoice{box,top,middle,center,bottom,none} (initially box),
+ axis x line*=\mchoice{box,top,middle,center,bottom,none} (initially box),
+ axis y line=\mchoice{box,left,middle,center,right,none} (initially box),
+ axis y line*=\mchoice{box,left,middle,center,right,none} (initially box)}
+Allows to choose the location of the axis line(s). Ticks and tick labels are placed accordingly.
+The choice |bottom| will draw the $x$ line at $y=y_\text{min}$, |middle| will draw the $x$~line at $y=0$, and |top| will draw it at $y=y_\text{max}$. Finally, |box| is a combination of options |top| and |bottom|. The $y$~variant works similarly.
+
+The case |center| is a synonym for |middle|, both draw the line through the respective coordinate~$0$. If this coordinate is not part of the axis limit, the lower axis limit is chosen instead.
+
+The starred versions $\dotsc$|line*| \emph{only} affect the axis lines, without correcting the positions of axis labels, tick lines or other keys which are (possibly) affected by a changed axis line. The non-starred versions are actually styles which set the starred key \emph{and} some other keys which also affect the figure layout:
+\begin{itemize}
+ \item In case |axis x line=box|, the style |every boxed x axis| will be installed immediately.
+ \item In case |axis x line|$\neq$|box|, the style |every non boxed x axis| will be installed immediately. Furthermore, axis labels positions will be adjusted to fit the choosen value.
+\end{itemize}
+The same holds true for the |y|-variants. The default styles are defined as
+\begin{codeexample}[code only]
+\pgfplotsset{
+ /pgfplots/every non boxed x axis/.style={
+ xtick align=center,
+ enlarge x limits=false,
+ x axis line style={-stealth}
+ },
+ /pgfplots/every boxed x axis/.style={}
+}
+\end{codeexample}
+Feel free to overwrite these styles if the default doesn't fit your needs or taste.
+
+\begin{codeexample}[]
+\begin{tikzpicture}
+\begin{axis}[
+ xlabel=$x$,ylabel=$\sin x$]
+
+ \addplot[blue,mark=none]
+ plot[id=sinneg,domain=-10:0,samples=40]
+ function{sin(x)};
+\end{axis}
+\end{tikzpicture}
+\end{codeexample}
+
\begin{codeexample}[]
\begin{tikzpicture}
\begin{axis}[
axis x line=middle,
axis y line=right,
- tick align=center,
ymax=1.1, ymin=-1.1,
- enlargelimits=false
+ xlabel=$x$,ylabel=$\sin x$
]
\addplot[blue,mark=none]
plot[id=sinneg,domain=-10:0,samples=40]
@@ -1681,10 +2039,24 @@ By default the axis lines are drawn as a |box|, but it is possible to change the
\begin{codeexample}[]
\begin{tikzpicture}
\begin{axis}[
- enlargelimits=false,
+ axis x line=bottom,
+ axis y line=left,
+ xlabel=$x$,ylabel=$\sqrt{|x|}$
+]
+\addplot[blue,mark=none]
+ plot[id=sqrtabsx,domain=-4:4,samples=501]
+ function{sqrt(abs(x))};
+\end{axis}
+\end{tikzpicture}
+\end{codeexample}
+
+\begin{codeexample}[]
+\begin{tikzpicture}
+\begin{axis}[
minor tick num=3,
axis y line=center,
- axis x line=middle
+ axis x line=middle,
+ xlabel=$x$,ylabel=$\sin x$
]
\addplot[blue,mark=none]
plot[domain=-5:5,samples=40]
@@ -1693,8 +2065,212 @@ By default the axis lines are drawn as a |box|, but it is possible to change the
\end{tikzpicture}
\end{codeexample}
+\begin{codeexample}[]
+\begin{tikzpicture}
+\begin{axis}[
+ minor tick num=3,
+ axis y line=left,
+ axis x line=middle,
+ xlabel=$x$,ylabel=$\sin x$
+ ]
+ \addplot[blue,mark=none]
+ plot[domain=-5:5,samples=40]
+ (\x,{sin(\x r)});
+\end{axis}
+\end{tikzpicture}
+\end{codeexample}
+
+In case |middle|, the style |every inner axis x line| allows to adjust the appearenace.
+\end{pgfplotskeylist}
+
+\begin{pgfplotsxykey}{every inner \x\ axis line}
+ A style key which can be redefined to customize the appearance of \emph{inner} axis lines. Inner axis lines are those drawn by the |middle| (or |center|) choice of |axis x line|, see above.
+
+ This style affects \emph{only} the line as such.
+\begin{codeexample}[]
+\begin{tikzpicture}
+\begin{axis}[
+ minor tick num=1,
+ axis x line=middle,
+ axis y line=middle,
+ every inner x axis line/.append style=
+ {|->>},
+ every inner y axis line/.append style=
+ {|->>},
+ xlabel=$x$,ylabel=$y^3$
+]
+\addplot[blue] plot[domain=-3:5] (\x,\x^3);
+\end{axis}
+\end{tikzpicture}
+\end{codeexample}
+\end{pgfplotsxykey}
+
+\begin{pgfplotsxykey}{every outer \x\ axis line}
+ Similar to |every inner x axis line|, this style configures the appearance of all axis lines which are part of the outer box.
+\begin{codeexample}[]
+\begin{tikzpicture}
+\begin{axis}[
+ separate axis lines, % important !
+ every outer x axis line/.append style=
+ {-stealth},
+ every outer y axis line/.append style=
+ {-stealth},
+]
+\addplot[blue] plot[id=DoG,
+ samples=100,
+ domain=-15:15]
+ function{1.3*exp(-x**2/10) - exp(-x**2/20)};
+\end{axis}
+\end{tikzpicture}
+\end{codeexample}
+\end{pgfplotsxykey}
+
+\begin{pgfplotskey}{separate axis lines=\marg{true,false} (default true)}
+ Enables or disables separate path commands for every axis line. This option affects \emph{only} the case if axis lines are drawn as a \emph{box}.
+
+ Both cases have their advantages and disadvantages, I fear there is no reasonable default (suggestions are welcome).
+
+ The case |separate axis lines=true| allows to draw arrow heads on each single axis line, but it can't close edges very well -- in case of thick lines, you will see unsatisfactory edges.
+\begin{codeexample}[]
+\begin{tikzpicture}
+\begin{axis}[
+ separate axis lines,
+ every outer x axis line/.append style=
+ {-stealth,red},
+ every outer y axis line/.append style=
+ {-stealth,green!30!black},
+]
+\addplot[blue] plot[id=DoG,
+ samples=100,
+ domain=-15:15]
+ function{1.3*exp(-x**2/10) - exp(-x**2/20)};
+\end{axis}
+\end{tikzpicture}
+\end{codeexample}
+
+ The case |separate axis lines=false| issues just \emph{one} path for all axis lines. It draws a kind of rectangle, where some parts of the rectangle may be skipped over if they are not wanted. The advantage is that edges are closed properly. The disadvantage is that at most one arrow head is added to the path (and yes, only one drawing color is possible).
+\begin{codeexample}[]
+\begin{tikzpicture}
+\begin{axis}[
+ separate axis lines=false,
+ every outer x axis line/.append style=
+ {-stealth,red},
+ every outer y axis line/.append style=
+ {-stealth,green!30!black},
+]
+\addplot[blue] plot[id=DoG,
+ samples=100,
+ domain=-15:15]
+ function{1.3*exp(-x**2/10) - exp(-x**2/20)};
+\end{axis}
+\end{tikzpicture}
+\end{codeexample}
+\end{pgfplotskey}
+
+
+\label{pgfplots:page:axislines}
+\begin{pgfplotskey}{axis line style=\marg{key-value-list}}
+ A command which appends \marg{key-value-list} to \emph{all} axis line appearance styles.
+\end{pgfplotskey}
+
+\begin{pgfplotskey}{inner axis line style=\marg{key-value-list}}
+ A command which appends \marg{key-value-list} to both, |every inner x axis line| and the $y$ variant.
+\end{pgfplotskey}
+\begin{pgfplotskey}{outer axis line style=\marg{key-value-list}}
+ A command which appends \marg{key-value-list} to both, |every outer x axis line| and the $y$ variant.
+\end{pgfplotskey}
+\begin{pgfplotsxykey}{\x\ axis line style=\marg{key-value-list}}
+ A command which appends \marg{key-value-list} to all axis lines styles for either $x$ or $y$ axis.
+\end{pgfplotsxykey}
+
+\begin{pgfplotsxykey}{every boxed \x\ axis}
+ A style which will be installed as soon as |axis x line=box| (|y|) is set.
+
+ The default is simply empty.
+\end{pgfplotsxykey}
+\begin{pgfplotsxykey}{every non boxed \x\ axis}
+ A style which will be installed as soon as |axis x line| (|y|) will be set to something different than |box|.
+
+ The default is
+\begin{codeexample}[code only]
+\pgfplotsset{
+ /pgfplots/every non boxed x axis/.style={
+ xtick align=center,
+ enlarge x limits=false,
+ x axis line style={-stealth}}}
+\end{codeexample}
+ \noindent with similar values for the |y|-variant. Feel free to redefine this style to your needs / taste.
+\end{pgfplotsxykey}
+
+\subsubsection[Two Ordinates]{Two Ordinates ($y$ axis)}
+{%
+\pgfplotsset{every axis/.append style={width=4.5cm}}%
+In some applications, more than one $y$ axis is used if the $x$ range is the same. This section demonstrates how to create them.
+
+\begin{codeexample}[]
+\begin{tikzpicture}
+ \begin{axis}[
+ scale only axis,
+ xmin=-5,xmax=5,
+ axis y line=left,
+ xlabel=$x$,
+ ylabel=First ordinate]
+ \addplot (\x,\x^2);
+ \end{axis}
+
+ \begin{axis}[
+ scale only axis,
+ xmin=-5,xmax=5,
+ axis y line=right,
+ axis x line=none,
+ ylabel=Second ordinate]
+ \addplot[red] (\x,3*\x);
+ \end{axis}
+\end{tikzpicture}
+\end{codeexample}
+\noindent The basic idea is to draw two axis ``on top'' of each other -- one, which contains the $x$ axis and the left $y$ axis, and one which has \emph{only} the right $y$ axis. This requires attention in the following possibly non-obvious aspects:
+\begin{enumerate}
+ \item Scaling. You should set |scale only axis| because this forces equal dimensions for both axis, without respecting any labels.
+ \item Same $x$ limits. You should set those limits explicitly.
+\end{enumerate}
+You may want to consider different legend styles.
+It is also possible to use only the axis, without any plots:
+\begin{codeexample}[]
+% \usepackage{textcomp}
+\begin{tikzpicture}
+ \begin{axis}[
+ scale only axis,
+ xmin=-5,xmax=5,
+ axis y line=left,
+ xlabel=$x$,
+ ylabel=Absolute]
+ \addplot (\x,\x^2);
+ \end{axis}
+
+ \begin{axis}[
+ scale only axis,
+ xmin=-5,xmax=5,
+ ymin=0,ymax=1000,
+ yticklabel=
+{$\pgfmathprintnumber{\tick}$\textperthousand},
+ axis y line=right,
+ axis x line=none,
+ y label style={yshift=-10pt},
+ ylabel=per thousand]
+ \end{axis}
+\end{tikzpicture}
+\end{codeexample}
+}
+
+\subsubsection{Axis Discontinuities}
In case the range of either of the axis do not include the zero value, it is possible to visualize this with a discontinuity decoration on the corresponding axis line.
+\begin{pgfplotsxykey}{axis \x\ discontinuity=\mchoice{crunch,parallel,none} (initially none)}
+Insert a discontinuity decoration on the $x$ (or $y$, respectively) axis.
+This is to visualize that the $y$ axis does cross the $x$ axis at its $0$ value, because the minimum $x$ axis value is positive or the maximum value is negative.
+
+The description applies |axis y discontinuity| as well, with interchanged meanings of $x$~and~$y$.
+
\begin{codeexample}[]
\begin{tikzpicture}
\begin{axis}[
@@ -1729,35 +2305,39 @@ In case the range of either of the axis do not include the zero value, it is pos
\end{axis}
\end{tikzpicture}
\end{codeexample}
+\end{pgfplotsxykey}
-\begin{pgfplotskey}{axis x line=\mchoice{box,top,middle,bottom,none} (initially box)}
-Allows to choose the location of the $x$ axis line(s).
-The labels and ticks are placed accordingly.
-Bottom will draw only a line at y=ymin, middle will draw a line at y=0, and top will draw only a line at y=ymax.
-Box is a combination of options top and bottom.
-\end{pgfplotskey}
-
-\begin{pgfplotskey}{axis y line=\mchoice{box,left,center,right,none} (initially box)}
-Allows to choose the location of the $y$ axis line(s).
-The labels and ticks are placed accordingly.
-Left will draw only a line at x=xmin, center will draw a line at x=0, and right will draw only a line at x=xmax.
-Box is a combination of options left and right.
-\end{pgfplotskey}
-\begin{pgfplotskey}{axis x discontinuity=\mchoice{crunch,parallel,none} (initially none)}
-Insert a discontinuity decoration on the $x$ axis.
-This is to visualize that the $y$ axis does cross the $x$ axis at its 0 value, because the minimum $x$ axis value is positive or the maximum value is negative.
-\end{pgfplotskey}
+\begin{pgfplotsxykey}{hide \x\ axis=\mchoice{true,false} (initially false)}
+Allows to hide either the $x$ or the $y$ axis. No outer rectangle, no tick marks and no labels will be drawn. Only titles and legends will be processed as usual.
-\begin{pgfplotskey}{axis y discontinuity=\mchoice{crunch,parallel,none} (initially none)}
-Similar to |axis x discontinuity|, but now for the $y$ axis.
-\end{pgfplotskey}
+Axis scaling and clipping will be done as if you did not use |hide x axis|.
+\begin{codeexample}[]
+\begin{tikzpicture}
+ \begin{axis}[
+ hide x axis,
+ hide y axis,
+ title={$\cos(x)$}]
+ \addplot (\x,{cos(\x)*\x^2});
+ \end{axis}
+\end{tikzpicture}
+\end{codeexample}
-\begin{pgfplotskey}{hide axis=\mchoice{true,false} (initially 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.
+\begin{codeexample}[]
+\begin{tikzpicture}
+ \begin{axis}[
+ hide x axis,
+ axis y line=left,
+ title={$\cos(x)$}]
+ \addplot (\x,{cos(\x)*\x^2});
+ \end{axis}
+\end{tikzpicture}
+\end{codeexample}
+\end{pgfplotsxykey}
-Axis scaling and clipping will be done as if you did not use |hide axis|.
-\end{pgfplotskey}
+\begin{stylekey}{/pgfplots/hide axis=\mchoice{true,false} (default true)}
+ A style which sets both, |hide x axis| and |hide y axis|.
+\end{stylekey}
\subsection{Scaling Options}
@@ -1779,7 +2359,7 @@ Sets the width of the final picture to \marg{dimen}. If no |height| is specified
\end{codeexample}
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 The \Tikz-options |x| and |y| which set the unit dimensions in $x$ and $y$ directions can be specified as arguments to |\begin{axis}[x=1.5cm,y=2cm]| if needed (see below). These settings override the |width| and |height| options.
\item You can also force a fixed width/height of the axis (without looking at labels) with
\begin{codeexample}[code only]
@@ -1809,7 +2389,7 @@ If |scale only axis=false| (the default), \PGFPlots\ will try to produce the des
\begin{pgfplotsxykey}{\x=\marg{dimen}}
Sets the unit size for one $x$ (or $y$) coordinate to \marg{dimen}.
- Setting $x$ explicitly overrides the \lstinline!width! option. Setting $y$ explicitly overrides the \lstinline!height! option.
+ Setting $x$ explicitly overrides the |width| option. Setting $y$ explicitly overrides the |height| option.
\begin{codeexample}[]
\begin{tikzpicture}
\begin{axis}[x=1cm,y=1cm]
@@ -1819,7 +2399,7 @@ Sets the unit size for one $x$ (or $y$) coordinate to \marg{dimen}.
\end{codeexample}
Setting |x| and/or |y| for logarithmic axis will set the dimension used for $1 \cdot e \approx 2.71828$.
- Please note that it is \emph{not} possible to specify \lstinline!x! as argument to \lstinline!tikzpicture!. The option
+ Please note that it is \emph{not} possible to specify |x| as argument to |tikzpicture|. The option
\begin{codeexample}[code only]
\begin{tikzpicture}[x=1.5cm]
\begin{axis}
@@ -1827,7 +2407,7 @@ Sets the unit size for one $x$ (or $y$) coordinate to \marg{dimen}.
\end{axis}
\end{tikzpicture}
\end{codeexample}
- won't have any effect because an axis rescales its coordinates (see the \lstinline!width! option).
+ won't have any effect because an axis rescales its coordinates (see the |width| option).
\end{pgfplotsxykey}
\subsection{Error Bars}
@@ -1836,16 +2416,16 @@ Sets the unit size for one $x$ (or $y$) coordinate to \marg{dimen}.
\def\pgfplotserror#1{\ensuremath{\epsilon_{#1}}}%
\PGFPlots\ supports error bars for normal and logarithmic plots.
-Error bars are enabled for each plot separately, using \meta{behavior options} after \lstinline!\addplot!:
+Error bars are enabled for each plot separately, using \meta{behavior options} after |\addplot|:
\begin{codeexample}[code only]
-\addplot plot[/pgfplots/error bars/.cd,x dir=both,y dir=both] ...
+\addplot plot[error bars/.cd,x dir=both,y dir=both] ...
\end{codeexample}
Error bars inherit all drawing options of the associated plot, but they use their own marker and style arguments additionally.
\begin{codeexample}[]
\begin{tikzpicture}
\begin{axis}
-\addplot plot[/pgfplots/error bars/.cd,
+\addplot plot[error bars/.cd,
y dir=plus,y explicit]
coordinates {
(0,0) +- (0.5,0.1)
@@ -1860,7 +2440,7 @@ coordinates {
\begin{codeexample}[]
\begin{tikzpicture}
\begin{axis}
-\addplot plot[/pgfplots/error bars/.cd,
+\addplot plot[error bars/.cd,
y dir=both,y explicit,
x dir=both,x fixed=0.05,
error mark=diamond*]
@@ -1874,12 +2454,13 @@ coordinates {
\end{tikzpicture}
\end{codeexample}
+\pgfplotsset{anchor=center,/tikz/every picture/.append style={baseline}}
\begin{codeexample}[]
\pgfplotstabletypesetfile{pgfplots.testtable2.dat}
\begin{tikzpicture}
\begin{loglogaxis}
-\addplot plot[/pgfplots/error bars/.cd,
+\addplot plot[error bars/.cd,
x dir=both,x fixed relative=0.5,
y dir=both,y explicit relative,
error mark=triangle*]
@@ -1904,7 +2485,7 @@ coordinates {
\begin{tikzpicture}
\begin{axis}[enlargelimits=false]
\addplot[red,mark=*]
- plot[/pgfplots/error bars/.cd,
+ plot[error bars/.cd,
y dir=minus,y fixed relative=1,
x dir=minus,x fixed relative=1,
error mark=none,
@@ -2025,10 +2606,24 @@ Please refer to the manual of \PGFPlotstable\ (shipped with this package) for de
\end{command}
\label{sec:identify:minor:log}%
-\begin{pgfplotskey}{log identify minor tick positions=\mchoice{true,false} (initially true)}
+\begin{pgfplotskey}{log identify minor tick positions=\mchoice{true,false} (initially false)}
Set this to |true| if you want to identify log--plot tick labels at positions
\[ i \cdot 10^j \]
-with $i \in \{2,3,4,5,6,7,8,9\},\, j \in \Z$. This may be valueable in conjunction with the `|extra x ticks|' and `|extra y ticks|' options. An example is shown below: The axis range is so small that only one tick label $10^j$ is inside of it. Extra tick labels can be placed on top of the normal ticks, and placing ticks at $i \cdot 10^j $ may be appropriate.
+with $i \in \{2,3,4,5,6,7,8,9\},\, j \in \Z$. This may be valueable in conjunction with the `|extra x ticks|' and `|extra y ticks|' options.
+\begin{codeexample}[]
+\begin{tikzpicture}%
+\begin{loglogaxis}
+ [title=Standard options,
+ width=6cm]
+\addplot coordinates {
+ (1e-2,10)
+ (3e-2,100)
+ (6e-2,200)
+};
+\end{loglogaxis}
+\end{tikzpicture}%
+\end{codeexample}
+
\begin{codeexample}[]
\pgfplotsset{every axis/.append style={%
width=6cm,
@@ -2036,9 +2631,13 @@ with $i \in \{2,3,4,5,6,7,8,9\},\, j \in \Z$. This may be valueable in conjuncti
extra x ticks={3e-2,6e-2},
extra x tick style={major tick length=0pt,font=\footnotesize}
}}%
+
\begin{tikzpicture}%
\begin{loglogaxis}[
- title=with minor tick identification]
+ xtick={1e-2},
+ title=with minor tick identification,
+ extra x tick style={
+ log identify minor tick positions=true}]
\addplot coordinates {
(1e-2,10)
(3e-2,100)
@@ -2049,8 +2648,10 @@ with $i \in \{2,3,4,5,6,7,8,9\},\, j \in \Z$. This may be valueable in conjuncti
\begin{tikzpicture}%
\begin{loglogaxis}[
+ xtick={1e-2},
title=without minor tick identification,
- log identify minor tick positions=false]
+ extra x tick style={
+ log identify minor tick positions=false}]
\addplot coordinates {
(1e-2,10)
(3e-2,100)
@@ -2059,6 +2660,7 @@ with $i \in \{2,3,4,5,6,7,8,9\},\, j \in \Z$. This may be valueable in conjuncti
\end{loglogaxis}%
\end{tikzpicture}%
\end{codeexample}
+ This key is set by the default styles for extra ticks.
\end{pgfplotskey}
\begin{pgfplotscodekey}{log number format code}
@@ -2154,7 +2756,7 @@ Allows to configure the number format of log plot exponents. This style is insta
% \let\pgfmathprintnumber@fixed@style=\myfixedpointstyle}
% }%
% \end{codeexample}
-% You only need to overwrite the macro \lstinline!\pgfmathprintnumber@fixed@style!. This macro takes one argument (the result of any numerical computations). The \TeX-boolean \lstinline!\ifpgfmathfloatroundhasperiod! is true if and only if the input number contains a period.
+% You only need to overwrite the macro |\pgfmathprintnumber@fixed@style|. This macro takes one argument (the result of any numerical computations). The \TeX-boolean |\ifpgfmathfloatroundhasperiod| is true if and only if the input number contains a period.
%
% \item An example for a new scientific display style:
% \begin{lstlisting}
@@ -2185,11 +2787,34 @@ Allows to configure the number format of log plot exponents. This style is insta
\begin{pgfplotsxykeylist}{\x min=\marg{coord},\x max=\marg{coord}}
The options |xmin|, |xmax| and |ymin|, |ymax| allow to define the axis limits, i.e. the lower left and the upper right corner. Everything outside of the axis limits will be clipped away.
-If one of \lstinline!xmin! or \lstinline!xmax! is missing, the $x$-interval will be determined automatically. The same holds true if one of \lstinline!ymin! or \lstinline!ymax! is missing: in this case, the $y$-interval will be determined automatically.
+Each missing limit will be determined automatically.
-If $x$-limits have been specified explicitly and $y$-limits are computed automatically, the automatic computation of $y$-limits will only considers points which fall into the specified $x$-range (and vice--versa). This can be disable using |clip limits=false|.
+If $x$-limits have been specified explicitly and $y$-limits are computed automatically, the automatic computation of $y$-limits will only considers points which fall into the specified $x$-range (and vice--versa). The same holds true if, for example, only |xmin| has been provided explicitly: in that case, |xmax| will be updated only for points for which $x \ge $|xmin| holds. This feature can be disable using |clip limits=false|.
Axis limits can be increased automatically using the |enlargelimits| option.
+\begin{codeexample}[]
+\begin{tikzpicture}
+ \begin{axis}
+ \addplot (\x,\x^2);
+ \end{axis}
+\end{tikzpicture}
+\end{codeexample}
+
+\begin{codeexample}[]
+\begin{tikzpicture}
+ \begin{axis}[xmin=0]
+ \addplot (\x,\x^2);
+ \end{axis}
+\end{tikzpicture}
+\end{codeexample}
+
+\begin{codeexample}[]
+\begin{tikzpicture}
+ \begin{axis}[ymax=10]
+ \addplot (\x,\x^2);
+ \end{axis}
+\end{tikzpicture}
+\end{codeexample}
\end{pgfplotsxykeylist}
\begin{pgfplotsxykey}{\x mode=\mchoice{normal,linear,log} (initially normal)}
@@ -2202,32 +2827,39 @@ Allows to choose between linear (=normal) or logarithmic axis scaling or logplot
This option has nothing to do with path clipping, it only affects how the axis limits are computed.
\end{pgfplotskey}
-\begin{pgfplotskey}{enlargelimits=\mchoice{true,false,auto,\marg{val}}}
-Enlarges the axis size somewhat if enabled.
+\begin{pgfplotsxykey}{enlarge \x\ limits=\mchoice{true,false,auto,\marg{val}} (default true)}
+Enlarges the axis size for one axis somewhat if enabled.
-You can set |xmin|, |xmax| and |ymin|, |ymax| to the minimum/maximum values of your data and |enlargelimits| will enlarge the canvas such that the axis doesn't touch the plots.
+You can set |xmin|, |xmax| and |ymin|, |ymax| to the minimum/maximum values of your data and |enlarge x limits| will enlarge the canvas such that the axis doesn't touch the plots.
\begin{itemize}
\item The value |true| enlarges all axes.
\item The value |false| uses tight axis limits as specified by the user (or read from input coordinates).
\item The value |auto| will enlarge limits only for axis for which axis limits have been determined automatically.
- \item All other values like `|enlargelimits=0.1|' will enlarge all axis limits relatively (in this example, 10\% of the axis limits will be added at all sides).
+ \item All other values like `|enlarge x limits=0.1|' will enlarge all axis limits relatively (in this example, 10\% of the axis limits will be added at all sides).
\end{itemize}
-A small value of |enlargelimits| may avoid problems with large markers near the boundary.
-\end{pgfplotskey}
+A small value of |enlarge x limits| may avoid problems with large markers near the boundary.
+\end{pgfplotsxykey}
+\begin{stylekey}{/pgfplots/enlargelimits=\mchoice{true,false,auto,\marg{val}} (default true)}
+ A style which sets |enlarge x limits| and |enlarge y limits| to the specified value.
+\end{stylekey}
+
+\begin{environment}{{pgfplotsinterruptdatabb}}
+ Everything in \marg{environment contents} will not contribute to the data bounding box.
+\end{environment}
\subsection{Tick and Grid Options}
\begin{pgfplotsxykey}{\x tick=\mchoice{\textbackslash empty,data,\marg{coordinate list}} (initially \marg{})}
The options |xtick| and |ytick| assigns a list of \emph{Positions} where ticks shall be placed. The argument is either the command |\empty|, |data| or a list of coordinates. The choice |\empty| will result in no tick at all. The special value |data| will produce tick marks at every coordinate of the first plot. Otherwise, tick marks will be placed at every coordinate in \marg{coordinate list}. If this list is empty, \PGFPlots\ will compute a default list.
-\marg{coordinate list} will be used inside of a \lstinline!\foreach \x in !\marg{coordinate list} statement. The format is as follows:
+\marg{coordinate list} will be used inside of a |\foreach \x in |\marg{coordinate list} statement. The format is as follows:
\begin{itemize}
- \item \lstinline!{0,1,2,5,8,1e1,1.5e1}! (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 |{0,1,2,5,8,1e1,1.5e1}| (a series of coordinates),
+ \item |{0,...,5}| (the same as |{0,1,2,3,4,5}|),
+ \item |{0,2,...,10}| (the same as |{0,2,4,6,8,10}|),
+ \item |{9,...,3.5}| (the same as |{9, 8, 7, 6, 5, 4}|),
\item See \cite[Section~34]{tikz} for a more detailed definition of the options.
\end{itemize}
For logplots, \PGFPlots\ will apply $\log(\cdot)$ to each element in `\marg{coordinate list}'.
@@ -2255,11 +2887,13 @@ For logplots, \PGFPlots\ will apply $\log(\cdot)$ to each element in `\marg{coor
\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 is to place ticks at positions $10^i$ in the axis' range. Which positions depends on the axis scaling and the dimensions of the picture. The default tick positions can be reconfigured with
+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 is to place ticks at positions $10^i$ in the axis' range. Which positions depends on the axis scaling and the dimensions of the picture. If log plots contain just one (or two) positions $10^i$ in their limits, ticks will be placed at positions $10^{i\cdot h}$ with ``feasable'' step sizes $h$ as in the case of linear axis.
+
+The default tick positions can be reconfigured with
\begin{itemize}
- \item `\lstinline!max space between ticks=!\marg{number}' where the integer argument denotes the maximum space between adjacent ticks in full points. The suffix ``|pt|'' has to be omitted and fractional numbers are not supported. The default is~\axisdefaulttickwidth.
- \item `\lstinline!try min ticks=!\marg{number}' configures a loose lower bound on the number of ticks. It should be considered as a suggestion, not a tight limit. The default is~\axisdefaulttryminticks. This number will increase the number of ticks if `|max space between ticks|' produces too few of them.
- \item `\lstinline!try min ticks log=!\marg{number}' The same for logarithmic axis.
+ \item `|max space between ticks=|\marg{number}' where the integer argument denotes the maximum space between adjacent ticks in full points. The suffix ``|pt|'' has to be omitted and fractional numbers are not supported. The default is~\axisdefaulttickwidth.
+ \item `|try min ticks=|\marg{number}' configures a loose lower bound on the number of ticks. It should be considered as a suggestion, not a tight limit. The default is~\axisdefaulttryminticks. This number will increase the number of ticks if `|max space between ticks|' produces too few of them.
+ \item `|try min ticks log=|\marg{number}' The same for logarithmic axis.
\end{itemize}
The total number of ticks may still vary because not all fractional numbers in the axis' range are valid tick positions.
@@ -2275,9 +2909,38 @@ or
\pgfplotsset{every tick/.append style={very thin,gray}}
\pgfplotsset{every minor tick/.append style={black}}
\end{codeexample}
-Please prefer the `|.append style|' versions to ensure compatibility with future versions.
+Please prefer the `|.append style|' versions whenever possible to ensure compatibility with future versions.
This style commands can be used at any time. The tick line width can be configured with `|major tick length|' and `|minor tick length|'.
+
+\begin{codeexample}[]
+\begin{tikzpicture}
+\begin{axis}[xtick=data,xmajorgrids]
+ \addplot coordinates {
+ (1,2)
+ (2,5)
+ (4,6.5)
+ (6,8)
+ (10,9)
+ };
+\end{axis}
+\end{tikzpicture}
+\end{codeexample}
+
+\begin{codeexample}[]
+\begin{tikzpicture}
+\begin{loglogaxis}[
+ title=A log plot with small axis range]
+
+ \addplot coordinates {
+ (10,1e-4)
+ (17,8.3176e-05)
+ (25,7.0794e-05)
+ (50,5e-5)
+ };
+\end{loglogaxis}
+\end{tikzpicture}
+\end{codeexample}
\end{pgfplotsxykey}
\begin{pgfplotskey}{minor tick num=\marg{number}}
@@ -2304,7 +2967,7 @@ This style commands can be used at any time. The tick line width can be configur
\end{pgfplotskey}
-\begin{pgfplotsxykey}{minor \x~tick num=\marg{number} (initially 0)}
+\begin{pgfplotsxykey}{minor \x\ tick num=\marg{number} (initially 0)}
Sets the number of minor tick lines used for linear $x$~or~$y$ axis separately.
Minor ticks will be disabled if the major ticks don't have the same distance.
@@ -2332,7 +2995,7 @@ Adds \emph{additional} tick positions and tick labels to the $x$~or~$y$ axis. `A
extra y tick labels={$e$},
extra x ticks={2.2},
extra x tick style={grid=major,
- /pgfplots/tick label style={
+ tick label style={
rotate=90,anchor=east}},
extra x tick labels={Cut},
]
@@ -2344,7 +3007,9 @@ Adds \emph{additional} tick positions and tick labels to the $x$~or~$y$ axis. `A
\begin{codeexample}[]
\pgfplotsset{every axis/.append style={width=5.3cm}}
\begin{tikzpicture}
-\begin{loglogaxis}
+\begin{loglogaxis}[
+ xtickten={1,2},
+ ytickten={-5,-6}]
\addplot coordinates
{(10,1e-5) (20,5e-6) (40,2.5e-6)};
\end{loglogaxis}
@@ -2352,6 +3017,8 @@ Adds \emph{additional} tick positions and tick labels to the $x$~or~$y$ axis. `A
\begin{tikzpicture}
\begin{loglogaxis}[
+ xtickten={1,2},
+ ytickten={-5,-6},
extra x ticks={20,40},
extra y ticks={5e-6,2.5e-6}]
\addplot coordinates
@@ -2362,6 +3029,8 @@ Adds \emph{additional} tick positions and tick labels to the $x$~or~$y$ axis. `A
\begin{tikzpicture}
\begin{loglogaxis}[
log identify minor tick positions=false,
+ xtickten={1,2},
+ ytickten={-5,-6},
extra x ticks={20,40},
extra y ticks={5e-6,2.5e-6}]
\addplot coordinates
@@ -2471,16 +3140,16 @@ This is one of two options to assign tick labels directly. The other option is `
The argument \marg{command} can be any \TeX-text. The following commands are valid inside of \marg{command}:
\begin{description}
- \item[\textbackslash tick] The current element of option \lstinline!xtick! (or \lstinline!ytick!).
+ \item[\textbackslash tick] The current element of option |xtick| (or |ytick|).
\item[\textbackslash ticknum] The current tick number, starting with~0 (a counter).
\item[\textbackslash nexttick] This command is only valid in case if the |x tick label as interval| option is set (or the corresponding variable for~$y$). It will contain the position of the next tick position, that means the right boundary of the tick interval.
\end{description}
The default argument is
\begin{itemize}
- \item \lstinline!\axisdefaultticklabel! for normal plots and
- \item \lstinline!\axisdefaultticklabellog! for logplots, see below.
+ \item |\axisdefaultticklabel| for normal plots and
+ \item |\axisdefaultticklabellog| for logplots, see below.
\end{itemize}
-(the same holds for \lstinline!yticklabel!). The defaults are set to
+(the same holds for |yticklabel|). The defaults are set to
\begin{codeexample}[code only]
\def\axisdefaultticklabel{%
$\pgfmathprintnumber{\tick}$%
@@ -2556,9 +3225,13 @@ which has the same effect as the `|every x tick label|' statement above. This is
\end{pgfplotsxykey}
\label{sec:scaled:ticks}%
-\begin{pgfplotskey}{scaled ticks=\mchoice{true,false} (initially true)}
+\begin{pgfplotsxykeylist}{
+ scaled \x\ ticks=\mchoice{true,false} (initially true),
+ scaled ticks=\mchoice{true,false} (initially true)}
Allows to factor out common exponents in tick labels. For example, if you have tick labels $20000,40000$ and $60000$, you may want to save some space and write $2,4,6$ with a separate factor `$\cdot 10^4$'. Use `|scaled ticks=true|' to enable this feature (default is |true|).
+ The |scaled ticks| key is a style which simply enables scaled ticks for both, $x$ and $y$.
+
\begin{codeexample}[]
\begin{tikzpicture}
\begin{axis}[scaled ticks=true]
@@ -2582,7 +3255,7 @@ Allows to factor out common exponents in tick labels. For example, if you have t
\end{axis}
\end{tikzpicture}
\end{codeexample}
-\end{pgfplotskey}
+\end{pgfplotsxykeylist}
\begin{pgfplotscodekey}{tick scale label code}
Allows to change the default code for scaled tick labels. The default is
@@ -2606,15 +3279,87 @@ Allows fine tuning of the '|scaled ticks|' algorithm: if the axis limits are of
\end{pgfplotskey}
-\begin{pgfplotskey}{tickpos=\mchoice{left,right,both} (initially both)}
-Allows to choose where to place the small tick lines. Default is ``|both|''. This setting applies to both $x$~and~$y$ axis where ``left'' and ``right'' mean ``bottom'' and ``top'' for~$y$.
+\begin{pgfplotsxykey}{\x tick pos=\mchoice{left,right,both} (initially both)}
+Allows to choose where to place the small tick lines. In the default configuration, this does also affect tick \emph{labels}, see below.
+
+For $y$, the additional choices |bottom| and |top| can be used which are equivalent to |left| and |right|, respectively. Both are accepted for $y$.
+\end{pgfplotsxykey}
+
+\begin{pgfplotskey}{tickpos=\mchoice{left,right,both}}
+ A style which sets both, |xtick pos| and |ytick pos|.
\end{pgfplotskey}
-\begin{pgfplotskey}{tick align=\mchoice{inside,center,outside} (initially inside)}
-Allows to change the location of the ticks relative to the axis lines.
-Default is ``|inside|''. this setting applies to both $x$~and~$y$ axis.
+\begin{pgfplotsxykey}{\x ticklabel pos=\mchoice{left,right,default} (initially default)}
+Allows to choose where to place tick \emph{labels}. The choices |left| and |right| place tick labels either at the left or at the right side of the complete axis. The choice |default| uses the same setting as |xtick pos| (or |ytick pos|). This option is only useful for boxed axis -- keep it to |default| for non-boxed figures.
+
+For $y$, the additional choices |bottom| and |top| can be used which are equivalent to |left| and |right|, respectively. Both are accepted for $y$.
+\end{pgfplotsxykey}
+
+\begin{pgfplotskey}{ticklabelpos=\mchoice{left,right,default}}
+ A style which sets both, |xticklabel pos| and |yticklabel pos|.
\end{pgfplotskey}
+\begin{pgfplotsxykey}{\x tick align=\mchoice{inside,center,outside} (initially inside)}
+Allows to change the location of the ticks relative to the axis lines.
+Default is ``|inside|''.
+\begin{codeexample}[]
+\begin{tikzpicture}
+\begin{axis}[
+ xtick=data,ytick=data,
+ xtick align=center,
+ axis x line=center,
+ axis y line=center,
+ enlargelimits=0.05]
+\addplot coordinates
+ {(-3,0) (-2,0.1) (-1,-0.6)
+ (0,1)
+ (1,-0.6) (2,0.1) (3,0)};
+\end{axis}
+\end{tikzpicture}
+\end{codeexample}
+
+\begin{codeexample}[]
+\begin{tikzpicture}
+\begin{axis}[
+ xtick=data,ytick=data,
+ axis x line=bottom,
+ ytick align=outside,
+ axis y line=left,
+ enlargelimits=0.05]
+\addplot coordinates
+ {(-3,0) (-2,0.1) (-1,-0.6)
+ (0,1)
+ (1,-0.6) (2,0.1) (3,0)};
+\end{axis}
+\end{tikzpicture}
+\end{codeexample}
+
+\begin{codeexample}[]
+\begin{tikzpicture}
+\begin{axis}[
+ xtick=data,
+ axis x line=center,
+ xticklabels={,,},
+ ytick={-0.6,0,0.1,1},
+ yticklabels={
+ $-\frac{6}{10}$,,
+ $\frac{1}{10}$,$1$},
+ ymajorgrids,
+ axis y line=left,
+ enlargelimits=0.05]
+\addplot coordinates
+ {(-3,0) (-2,0.1) (-1,-0.6)
+ (0,1)
+ (1,-0.6) (2,0.1) (3,0)};
+\end{axis}
+\end{tikzpicture}
+\end{codeexample}
+\end{pgfplotsxykey}
+
+\begin{stylekey}{/pgfplots/tick align=\mchoice{inside,center,outside} (initially inside)}
+ A style which sets both, |xtick align| and |ytick align| to the specified value.
+\end{stylekey}
+
\begin{pgfplotsxykeylist}{\x minorticks=\mchoice{true,false} (initially true),\x majorticks=\mchoice{true,false} (initially true),ticks=\mchoice{minor,major,both,none} (initially both)}
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 between tick positions. Please note that minor ticks are automatically disabled if |xtick| is not a uniform range\footnote{A uniform list means the difference between all elements is the same for linear axis or, for logarithmic axes, $\log(10)$.}.
@@ -2676,15 +3421,15 @@ Grid lines will be drawn before tick lines are processed, so ticks will be drawn
\subsection{Style Options}
\label{sec:styles}
\subsubsection{All Supported Styles}
-\PGFPlots\ provides many styles to customize its appearance and behavior. They can be defined and changed in any place where keys are allowed.
+\PGFPlots\ provides many styles to customize its appearance and behavior. They can be defined and changed in any place where keys are allowed. Furthermore, own styles are defined easily.
-\begin{handler}{.style=\marg{key-value-list}}
+\begin{handler}{{.style}=\marg{key-value-list}}
Defines or redefines a style \meta{key}. A style is a normal key which will set all options in \marg{key-value-list} when it is set.
Use |\pgfplotsset{|\meta{key}|/.style={|\meta{key-value-list}|}}| to (re-) define a style \meta{key} in the namespace |/pgfplots|.
\end{handler}
-\begin{handler}{.append style=\marg{key-value-list}}
+\begin{handler}{{.append style}=\marg{key-value-list}}
Appends \marg{key-value-list} to an already existing style \meta{key}. This is the preferred method to change the predefined styles: if you only append, you maintain compatibility with future versions.
Use |\pgfplotsset{|\meta{key}|/.append style={|\meta{key-value-list}|}}| to append \marg{key-value-list} to the style \meta{key}. This will assume the prefix |/pgfplots|.
@@ -2698,32 +3443,38 @@ Grid lines will be drawn before tick lines are processed, so ticks will be drawn
You can define new style keys with |.style| and |.append style|, see above.
\end{command}
-\begin{stylekey}{/pgfplots/every axis}
+\subsubsection*{Styles installed for linear/logarithmic axis}
+
+\begin{stylekey}{/pgfplots/every axis (initially empty)}
Installed at the beginning of every axis. \Tikz\ options inside of it will be used for anything inside of the axis rectangle and any axis descriptions.
\end{stylekey}
-\begin{stylekey}{/pgfplots/every semilogx axis}
+\begin{stylekey}{/pgfplots/every semilogx axis (initially empty)}
Installed at the beginning of every plot with linear $x$~axis and logarithmic $y$~axis, but after `|every axis|'.
\end{stylekey}
-\begin{stylekey}{/pgfplots/every semilogy axis}
+\begin{stylekey}{/pgfplots/every semilogy axis (initially empty)}
Likewise, but with interchanged roles for $x$~and~$y$.
\end{stylekey}
-\begin{stylekey}{/pgfplots/every loglog axis}
+\begin{stylekey}{/pgfplots/every loglog axis (initially empty)}
Installed at the beginning of every double--logarithmic plot.
\end{stylekey}
-\begin{stylekey}{/pgfplots/every linear axis}
+\begin{stylekey}{/pgfplots/every linear axis (initially empty)}
Installed at the beginning of every plot with normal axis scaling.
\end{stylekey}
-\begin{stylekey}{/pgfplots/every axis plot}
- Used for the \Tikz-drawing command in any `\lstinline!\addplot!' command. May only contain \Tikz\ options.
+\subsubsection*{Styles installed for single plots}
+
+\begin{stylekey}{/pgfplots/every axis plot (initially empty)}
+ Installed for each plot. This style may contain \meta{behavior options} like samples, gnuplot parameters, error bars and it may contain \meta{style options} which affect the final drawing commands.
+
+% \FIXME{currently, pgfplots options need to be prefixed with /pgfplots/}
\end{stylekey}
-\begin{stylekey}{/pgfplots/every axis plot post}
- This style is very similar to |every axis plot| in that is applies to any drawing command in |\addplot|. However, it is set \emph{after} any user defined styles or |cycle list| options.
+\begin{stylekey}{/pgfplots/every axis plot post (initially empty)}
+ This style is similar to |every axis plot| in that is applies to any drawing command in |\addplot|. However, it is set \emph{after} any user defined styles or |cycle list| options.
\begin{codeexample}[]
\begin{tikzpicture}
\pgfplotsset{
@@ -2742,175 +3493,223 @@ Grid lines will be drawn before tick lines are processed, so ticks will be drawn
\end{codeexample}
\end{stylekey}
-\begin{stylekey}{/pgfplots/every axis plot no \#}
- Used for every \#th plot where $\#=1,2,3,4,\dotsc$.
+\begin{stylekey}{/pgfplots/every axis plot no \# (initially empty)}
+ Used for every \#th plot where $\#=1,2,3,4,\dotsc$. This option may also contain \meta{behavior options}.
\end{stylekey}
-\begin{stylekey}{/pgfplots/every axis label}
- Used for $x$~and~$y$ axis label. You can use `|at=|\marg{(x,y)} to set its position where $(0,0)$ refers to the lower left corner and $(1,1)$ to the upper right one.
-\end{stylekey}
+\subsubsection*{Styles for axis descriptions}
-\begin{stylekey}{/pgfplots/every axis x label}
- Used for $x$~labels, installed after `|every axis label|'.
+\begin{stylekey}{/pgfplots/every axis label (initially empty)}
+ Used for $x$~and~$y$ axis label. You can use `|at=|\parg{x,y} to set its position where $(0,0)$ refers to the lower left corner and $(1,1)$ to the upper right one.
\end{stylekey}
-\begin{stylekey}{/pgfplots/every axis y label}
- Like `|every axis x label|', just for~$y$.
-\end{stylekey}
+\pgfplotsshortstylekey label style=every axis label;
-\begin{stylekey}{/pgfplots/every axis title}
- Used for any axis title. The |at=|\marg{(x,y)} command works as for `|every axis label|'.
-\end{stylekey}
+\begin{xystylekey}{/pgfplots/every axis \x\ label}
+ Used only~$x$ or only for~$y$ labels, installed after `|every axis label|'.
-\begin{stylekey}{/pgfplots/every tick}
- Installed for each of the small tick lines.
-\end{stylekey}
-
-\begin{stylekey}{/pgfplots/every minor tick}
- Used for each minor tick line, installed after `|every tick|'.
-\end{stylekey}
+ The initial settings are
+\begin{codeexample}[code only]
+\pgfplotsset{
+ every axis x label/.style={at={(0.5,0)},below,yshift=-15pt},
+ every axis y label/.style={at={(0,0.5)},xshift=-35pt,rotate=90}}
+\end{codeexample}
-\begin{stylekey}{/pgfplots/every major tick}
- Used for each major tick line, installed after `|every tick|'.
-\end{stylekey}
+ The predefined node |current axis| can be used to refer to anchors of the unfinished picture. For example
+ `|at={(current axis.origin)}|' will position a label at the \emph{data} coordinate $(0,0)$. More useful is probably
+ `|at={(current axis.right of origin)}|', see
+ section~\ref{pgfplots:sec:align} for more details. This remark holds
+ for any axis description, but it is mostly useful for axis labels.
-\begin{stylekey}{/pgfplots/every x tick}
+\paragraph{Attention:} These styles will be overwritten by |axis x line| and/or |axis y line|. Please remember to place your modifications after the axis line variations.
+\end{xystylekey}
-\end{stylekey}
+\pgfplotsshortxystylekeys \x\ label style,\x label style=every axis \x\ label;
-\begin{stylekey}{/pgfplots/every minor x tick}
+\begin{stylekey}{/pgfplots/every axis title}
+ Used for any axis title. The |at=|\parg{x,y} command works as for `|every axis label|'.
+The initial setting is
+\begin{codeexample}[code only]
+\pgfplotsset{every axis title/.style={at={(0.5,1)},above,yshift=6pt}}
+\end{codeexample}
\end{stylekey}
-\begin{stylekey}{/pgfplots/every major x tick}
+\pgfplotsshortstylekey title style=every axis title;
+\begin{stylekey}{/pgfplots/every axis legend}
+ Installed for each legend. As for |every axis label|, the legend's position can be placed using coordinates between $0$~and~$1$, see above.
+
+ The initial setting is
+\begin{codeexample}[code only]
+\pgfplotsset{every axis legend/.style={
+ 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{codeexample}
\end{stylekey}
-\begin{stylekey}{/pgfplots/every y tick}
+\pgfplotsshortstylekey legend style=every axis legend;
-\end{stylekey}
+\subsubsection*{Styles for axis lines}
+\begin{xystylekey}{/pgfplots/every outer \x\ axis line (initially empty)}
+ Installed for every axis line which lies on the outer box.
-\begin{stylekey}{/pgfplots/every minor y tick}
+ If you want arrow heads, you may also need to check the |separate axis lines| boolean key.
+\end{xystylekey}
-\end{stylekey}
+\begin{xystylekey}{/pgfplots/every inner \x\ axis line (initially empty)}
+ Installed for every axis line which is drawn using the |center| or |middle| options.
+\end{xystylekey}
-\begin{stylekey}{/pgfplots/every major y tick}
+\begin{pgfplotsxykeylist}{%
+ axis line style=\marg{key-value-list},
+ inner axis line style=\marg{key-value-list},
+ outer axis line style=\marg{key-value-list},
+ \x\ axis line style=\marg{key-value-list}}
+ These options modify selects parts of the axis line styles. They set |every inner x axis line| and |every outer x axis line| and the respective $y$ variants.
+\end{pgfplotsxykeylist}
-\end{stylekey}
+\noindent
+Please refer to section~\ref{pgfplots:page:axislines} on page~\pageref{pgfplots:page:axislines} for details about styles for axis lines.
-\begin{stylekey}{/pgfplots/every axis grid}
- Used for each grid line.
-\end{stylekey}
-\begin{stylekey}{/pgfplots/every minor grid}
- Used for each minor grid line, installed after `|every axis grid|'.
-\end{stylekey}
-\begin{stylekey}{/pgfplots/every major grid}
- Likewise, for major grid lines.
+\subsubsection*{Styles for ticks}
+
+\begin{stylekey}{/pgfplots/every tick (initially very thin,gray)}
+ Installed for each of the small tick \emph{lines}.
\end{stylekey}
-\begin{stylekey}{/pgfplots/every axis x grid}
+\pgfplotsshortstylekey tick style=every tick;
+\begin{stylekey}{/pgfplots/every minor tick (initially empty)}
+ Used for each minor tick line, installed after `|every tick|'.
\end{stylekey}
-\begin{stylekey}{/pgfplots/every minor x grid}
+\pgfplotsshortstylekey minor tick style=every minor tick;
+\begin{stylekey}{/pgfplots/every major tick (initially empty)}
+ Used for each major tick line, installed after `|every tick|'.
\end{stylekey}
-\begin{stylekey}{/pgfplots/every major x grid}
+\pgfplotsshortstylekey major tick style=every major tick;
+\begin{stylekey}{/pgfplots/every tick label (initially empty)}
+ Used for each $x$~and~$y$ tick labels.
\end{stylekey}
-\begin{stylekey}{/pgfplots/every axis y grid}
+\begin{xystylekey}{/pgfplots/every \x\ tick label (initially empty)}
+ Used for each $x$ (or $y$, respectively) tick label, installed after `|every tick label|'.
+\end{xystylekey}
-\end{stylekey}
+\pgfplotsshortxystylekeys \x\ tick label style,\x ticklabel style=every \x\ tick label;
-\begin{stylekey}{/pgfplots/every minor y grid}
+\begin{xystylekey}{/pgfplots/every \x\ tick scale label}
+ Configures placement and display of the nodes containing the order of magnitude of tick labels, see section~\ref{sec:scaled:ticks} for more information about |scaled ticks|.
-\end{stylekey}
+The initial settings are
+\begin{codeexample}[code only]
+\pgfplotsset{
+ every x tick scale label/.style={at={(1,0)},yshift=-2em,left,inner sep=0pt},
+ every y tick scale label/.style={at={(0,1)},above right,inner sep=0pt,yshift=0.3em}}
+\end{codeexample}
+\end{xystylekey}
-\begin{stylekey}{/pgfplots/every major y grid}
+\pgfplotsshortxystylekey \x\ tick scale label style=every \x\ tick scale label;
-\end{stylekey}
+\begin{xystylekey}{/pgfplots/every \x\ tick (initially empty)}
+ Installed for tick \emph{lines} on either $x$ or $y$ axis.
+\end{xystylekey}
-\begin{stylekey}{/pgfplots/every tick label}
- Used for each $x$~and~$y$ tick labels.
-\end{stylekey}
+\pgfplotsshortxystylekey \x\ tick style=every \x\ tick;
-\begin{stylekey}{/pgfplots/every x tick label}
- Used for each $x$~tick label, installed after `|every tick label|'.
-\end{stylekey}
+\begin{xystylekey}{/pgfplots/every minor \x\ tick (initially empty)}
+ Installed for minor tick lines on either $x$ or $y$ axis.
+\end{xystylekey}
-\begin{stylekey}{/pgfplots/every y tick label}
- Likewise, for $y$~tick labels.
-\end{stylekey}
+\pgfplotsshortxystylekey minor \x\ tick style=every minor \x\ tick;
-\begin{stylekey}{/pgfplots/every x tick scale label}
- Configures placement and display of the nodes containing the order of magnitude of $x$~tick labels, see~\ref{sec:scaled:ticks} for more information about |scaled ticks|.
-\end{stylekey}
+\begin{xystylekey}{/pgfplots/every major \x\ tick (initially empty)}
+ Installed for major tick lines on either $x$ or $y$ axis.
+\end{xystylekey}
+\pgfplotsshortxystylekey major \x\ tick style=every major \x\ tick;
-\begin{stylekey}{/pgfplots/every y tick scale label}
- Likewise, but for $y$-tick scale labels.
-\end{stylekey}
+\begin{xystylekey}{/pgfplots/every extra \x\ tick}
+ Allows to configure the appearance of `|extra x ticks|'. This style is installed before touching the first extra $x$~tick. It is possible to set any option which affects tick or grid line generation.
-\begin{stylekey}{/pgfplots/every extra x tick}
- Allows to configure the appearance of `|extra x ticks|'. This style is installed before touching the first extra $x$~tick, so you can set any option which affects tick generation, for example
-\end{stylekey}
+The initial setting is
+\begin{codeexample}[code only]
+\pgfplotsset{
+ every extra x tick/.style={/pgfplots/log identify minor tick positions=true},
+ every extra y tick/.style={/pgfplots/log identify minor tick positions=true}}
+\end{codeexample}
-\begin{stylekey}{/pgfplots/every error bar}
- Installed for every error bar.
+ Useful examples are shown below.
\begin{codeexample}[code only]
\pgfplotsset{every extra x tick/.append style={grid=major}}
\pgfplotsset{every extra x tick/.append style={major tick length=0pt}}
\pgfplotsset{every extra x tick/.append style={/pgf/number format=sci subscript}}
\end{codeexample}
-or something like that.
+\end{xystylekey}
+
+\pgfplotsshortxystylekey extra \x\ tick style=every extra \x\ tick;
+
+
+
+\subsubsection*{Styles for grid lines}
+
+\begin{stylekey}{/pgfplots/every axis grid (initially thin,black!25)}
+ Used for each grid line.
\end{stylekey}
-\begin{stylekey}{/pgfplots/every extra y tick}
- Likewise, but for extra $y$-ticks.
+\pgfplotsshortstylekey grid style=every axis grid;
+
+\begin{stylekey}{/pgfplots/every minor grid (initially empty)}
+ Used for each minor grid line, installed after `|every axis grid|'.
\end{stylekey}
-\begin{stylekey}{/pgfplots/every axis legend}
- Installed for each legend. As for |every axis label|, the legend's position can be placed using coordinates between $0$~and~$1$, see above.
+\pgfplotsshortstylekey minor grid style=every minor grid;
+
+\begin{stylekey}{/pgfplots/every major grid (initially empty)}
+ Likewise, for major grid lines.
\end{stylekey}
+\pgfplotsshortstylekey major grid style=every major grid;
-\begin{pgfplotsxykeylist}{%
- \x\ tick label style=\marg{$\dots$},
- \x\ tick scale label style=\marg{$\dots$},
- label style=\marg{$\dots$},
- \x\ label style=\marg{$\dots$},
- title style=\marg{$\dots$},
- tick style=\marg{$\dots$},
- minor tick style=\marg{$\dots$},
- major tick style=\marg{$\dots$},
- \x\ tick style=\marg{$\dots$},
- minor \x\ tick style=\marg{$\dots$},
- major \x\ tick style=\marg{$\dots$},
- grid style=\marg{$\dots$},
- minor grid style=\marg{$\dots$},
- major grid style=\marg{$\dots$},
- \x\ grid style=\marg{$\dots$},
- minor \x\ grid style=\marg{$\dots$},
- major \x\ grid style=\marg{$\dots$},
- extra \x\ tick style=\marg{$\dots$}}
-
-All these options are equivalent to the corresponding `|every ...|'--styles.
-
-For example, |label style=|\marg{...} has the same effect as
-\begin{codeexample}[code only]
-\pgfplotsset{every axis label/.append style={...}}
-\end{codeexample}
-but can be provided as an option (or as part of a user defined style).
-See section~\ref{sec:styles} for more information about the available styles.
-\end{pgfplotsxykeylist}
+\begin{xystylekey}{/pgfplots/every axis \x\ grid (initially empty)}
+ Used for each grid line in either $x$ or $y$ direction.
+\end{xystylekey}
+
+\pgfplotsshortxystylekey \x\ grid style=every axis \x\ grid;
+
+\begin{xystylekey}{/pgfplots/every minor \x\ grid (initially empty)}
+ Used for each minor grid line in either $x$ or $y$ direction.
+\end{xystylekey}
+
+\pgfplotsshortxystylekey minor \x\ grid style=every minor \x\ grid;
+
+\begin{xystylekey}{/pgfplots/every major \x\ grid (initially empty)}
+ Used for each major grid line in either $x$ or $y$ direction.
+\end{xystylekey}
+
+\pgfplotsshortxystylekey major \x\ grid style=every major \x\ grid;
+
+\subsubsection*{Styles for error bars}
-\subsubsection{Assigning Own Styles}
+\begin{stylekey}{/pgfplots/every error bar (initially thin)}
+ Installed for every error bar.
+\end{stylekey}
+
+\pgfplotsshortstylekey error bars/error bar style=every error bar;
+
+\subsubsection{(Re-)Defining Own Styles}
\label{sec:styles:own}%
Use |\pgfplotsset{|\meta{style name}|/.style=|\marg{key-value-list}|}|
-to create own styles. You \emph{can't use} |\tikzstyle|\marg{style name}|=[]|.
+to create own styles. If \meta{style name} exists already, it will be replaced. Please note that it is \emph{not} possible to use the \Tikz-command |\tikzstyle|\marg{style name}|=[]| in this context\footnote{This was possible in a previous version and is still supported for backwards compatibility. But in some cases, it may not work as expected.}.
\begin{codeexample}[]
\pgfplotsset{my personal style/.style=
{grid=major,font=\large}}
@@ -2923,6 +3722,7 @@ to create own styles. You \emph{can't use} |\tikzstyle|\marg{style name}|=[]|.
\end{codeexample}
\subsection{Alignment Options}
+\label{pgfplots:sec:align}
\begin{pgfplotskey}{anchor=\marg{name} (initially south west)}
\label{option:anchor}%
@@ -2930,7 +3730,7 @@ This option shifts the axis horizontally and vertically such that the axis ancho
Anchors are useful in conjunction with horizontal or vertical alignment of plots, see the examples below.
-There are three sets of anchors available: anchors positioned on the axis rectangle, anchors on the outer bounding box and anchors which have one coordinate on the outer bounding box and the other one at a position of the axis rectangle.
+There are four sets of anchors available: anchors positioned on the axis rectangle, anchors on the outer bounding box and anchors which have one coordinate on the outer bounding box and the other one at a position of the axis rectangle. Finally, one can place anchors near the origin.
{%
%\pgfplotsset{every picture/.append style={background rectangle/.style={help lines},show background rectangle}}%
@@ -2988,9 +3788,9 @@ Anchors on the outer bounding box,
\showit{outer center}{90}
\end{tikzpicture}
\end{center}
-Finally there are anchors which have one coordinate on the outer bounding box, and one on the axis rectangle,
+There are anchors which have one coordinate on the outer bounding box, and one on the axis rectangle,
\begin{center}
- \begin{tikzpicture}[show background rectangle]
+ \begin{tikzpicture}
\plot
{\pgfplotsset{every pin/.append style={pin distance=1cm}}%
\showit{above north}{90}
@@ -3010,7 +3810,37 @@ Finally there are anchors which have one coordinate on the outer bounding box, a
\showit{above north west}{90}
\end{tikzpicture}
\end{center}
-The default value is |anchor=south west|. You can use anchors in conjunction with the \Tikz\ |baseline| option and/or \lstinline!\begin{pgfinterruptboundingbox}! to perform alignment.
+And finally, we have origin anchors which are especially useful when axis lines pass through the origin,
+ \begin{center}
+ \begin{tikzpicture}
+ \begin{axis}[
+ name=test plot,
+ axis x line=center,
+ axis y line=center,
+ enlargelimits=false,
+ minor tick num=3,
+ tick style={semithick},
+ tick align=center,
+ xlabel=$x$,
+ ylabel=$y$,
+ every axis x label/.style={at={(current axis.right of origin)},anchor=north east},
+ every axis y label/.style={at={(current axis.above origin)},anchor=north east},
+ inner axis line style={->},
+ ]
+ \addplot plot[domain=-2:5] (\x,20*\x);
+ \end{axis}
+ {\pgfplotsset{every pin/.append style={pin distance=1cm}}%
+ \showit{above origin}{45}
+ }%
+ \showit{right of origin}{45}
+ {\pgfplotsset{every pin/.append style={pin distance=1cm}}%
+ \showit{below origin}{0}
+ }%
+ \showit{left of origin}{135}
+ \showit{origin}{135}
+ \end{tikzpicture}
+ \end{center}
+The default value is |anchor=south west|. You can use anchors in conjunction with the \Tikz\ |baseline| option and/or |\begin{pgfinterruptboundingbox}| to perform alignment.
}
\begin{description}
@@ -3094,7 +3924,7 @@ cycle list={
\item[Bounding box restrictions]
\label{sec:bounding:box:example}%
{%
-The following figure is centered and encapsulated with an \lstinline!\fbox! to show its bounding box.
+The following figure is centered and encapsulated with an |\fbox| to show its bounding box.
\setlength{\fboxsep}{0pt}%
\begin{codeexample}[]
\fbox{%
@@ -3128,12 +3958,110 @@ The |pgfinterruptboundingbox| environment does not include its content into the
\end{description}
\end{pgfplotskey}
+\begin{predefinednode}{current axis}
+ A node which refers to the current axis or the last typeset axis.
+
+ You can use this node in axis descriptions, for example to place axis labels or titles.
+
+ \paragraph{Remark:} If you use |current axis| inside of axis descriptions, the ``current axis'' is not yet finished. That means you \emph{can't use any outer anchor} inside of axis descriptions.
+\end{predefinednode}
+
\begin{pgfplotskey}{at=\marg{coordinate expression}}
-Assigns a position for the complete axis image. This option works similarly to the |at|-option of |\node[at=|\marg{coordinate expression}|]|, see~\cite{tikz}. The common syntax is |at=|\marg{(x,y)}.
+Assigns a position for the complete axis image. This option works similarly to the |at|-option of |\node[at=|\marg{coordinate expression}|]|, see~\cite{tikz}. The common syntax is |at=|\parg{x,y}.
+\end{pgfplotskey}
+
+\subsection{Symbolic Coordinates and User Transformations}
+\PGFPlots\ supports user transformations which can be applied to input and output coordinates. Suppose the plot shall display days versus account statements over time. Then, one wants to visualize date versus credit balance. But: dates need to be transformed to numbers before doing so! Furthermore, tick labels shall be displayed as dates as well. This, and more general transformations, can be realized using the |x coord trafo| and |y coord trafo| keys.
+
+\begin{pgfplotsxycodekeylist}{
+ \x\ coord trafo,
+ \x\ coord inv trafo}
+ These code keys allow arbitrary coordinate transformations which are applied to input coordinates and output tick labels.
+
+ The |x coord trafo| and |y coord trafo| command keys take one argument which is the input coordinate. They are expected to set |\pgfmathresult| to the final value.
+
+ At this level, the input coordinate is provided as it is found in the |\addplot| statement. For example, if $x$ coordinates are actually of the form \meta{year}-\meta{month}-\meta{day}, for example |2008-01-05|, then a useful coordinate transformation would transform this string into a number (see below for a predefined realization).
+
+ In short, \emph{no} numerics has been applied to input coordinates when this transformation is applied\footnote{Of course, if coordinates have been generated by gnuplot or \pgfname, this does no longer hold.}.
+
+ The input coordinate transformation is applied to
+ \begin{itemize}
+ \item any input coordinates (specified with |\addplot| or |axis cs|),
+ \item any user-specified |xtick| or |ytick| options,
+ \item any user-specified |extra x ticks| and |extra y ticks| options,
+ \item any user-specified axis limits like |xmin| and |xmax|.
+ \end{itemize}
+
+ The output coordinate transformation |x coord inv trafo| is applied to tick positions just before evaluating the |xticklabel| and |yticklabel| keys. The tick label code may use additional macros defined by the inverse transformation.
+
+ Remark: \PGFPlots\ will continue to produce tick positions as usual, no extra magic is applied. It may be necessary to provide tick positions explicitly if the default doesn't respect the coordinate space properly.
+
+ The initial value of these keys is
+\begin{codeexample}[code only]
+\pgfplotsset{
+ x coord trafo/.code={},
+ x coord inv trafo/.code={}}
+\end{codeexample}
+ \noindent which simply disables the transformation (the same for $y$, of course).
+\end{pgfplotsxycodekeylist}
+
+\subsubsection{Dates as input coordinates}
+The already mentioned application of using dates as input coordinates has been predefined. It relies on the \pgfname\ calendar library which converts dates to numbers in the julian calendar. Then, one coordinate unit is one day.
+
+\begin{tikzlibrary}{dateplot}
+ Loads the coordinate transformation code.
+\end{tikzlibrary}
+
+\begin{stylekey}{/pgfplots/date coordinates in=\mchoice{x,y}}
+ Installs |x coord trafo| and |x coord inv trafo| (or the respective $y$ variant) such that ISO dates of the form \meta{year}-\meta{month}-\meta{day} are accepted. For example, |2006-02-28| will be converted to an ``appropriate'' integer using the julian calender.
+
+ The result of the transformation are numbers where one unit is one day.
+
+ The transformation is realized using the \pgfname-calendar module, see \cite[Calendar Library]{tikz}. This reference also contains more information about extended syntax options.
+
+ The inverse transformation provides the following three macros which are available during tick label evaluation:
+ \begin{itemize}
+ \item |\year| expands to the year component,
+ \item |\month| expands to the month component,
+ \item |\day| expands to the day component.
+ \end{itemize}
+ This allows to use |\day.\month.\year| inside of |xticklabel|, for example.
+
+ A complete example (with fictional data) is shown below.
+\pgfplotsset{anchor=center,/tikz/every picture/.append style={baseline}}
+\begin{codeexample}[]
+% requires \usetikzlibrary{dateplot} !
+
+\pgfplotstabletypesetfile[string type]{plotdata/accounts.dat}
+
+\begin{tikzpicture}
+ \begin{axis}[
+ date coordinates in=x,
+ xticklabel={\day.\month.},
+ xlabel={2008},
+ stack plots=y,
+ yticklabel={\pgfmathprintnumber{\tick}\EUR{}}, % <- requires \usepackage{eurosym}
+ ylabel=Total credit,
+ ylabel style={yshift=10pt},
+ legend style={
+ at={(0.5,-0.3)},anchor=north,legend columns=-1}]
+
+ \addplot table[x=date,y=account1] {plotdata/accounts.dat};
+ \addplot table[x=date,y=account2] {plotdata/accounts.dat};
+ \addplot table[x=date,y=account3] {plotdata/accounts.dat};
+ \legend{Giro,Tagesgeld,Sparbuch}
+ \end{axis}
+\end{tikzpicture}
+\end{codeexample}
+\end{stylekey}
+
+\begin{pgfplotskey}{date ZERO=\meta{year}-\meta{month}-\meta{day} (initially 2006-01-01)}
+ A technical key which defines the $0$ coordinate of |date coordinates in|. Users will never see the resulting numbers, so one probably never needs to change it. However, the resulting numbers may become very large and a mantisse of 6 significant digits may not be enough to get accurate results. In this case, |date ZERO| should be set to a number which falls into the input date range.
\end{pgfplotskey}
+
\subsection{Miscellaneous Options}
\begin{pgfplotskey}{disablelogfilter=\mchoice{true,false} (initally false, default true)}
@@ -3148,10 +4076,10 @@ Disables internal re-scaling of input data. Normally, every input data like plot
\[ T(x) = 10^{q-m} \cdot x - a \]
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 magnitude} 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. This scaling allows precision beyond \TeX's capabilities.
+The \textbf{effect} of the transformation is that your plot coordinates can be of \emph{arbitrary magnitude} 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. This scaling allows precision beyond \TeX's capabilities.
%\footnote{Please note that while plot coordinates can be of quite large magnitude like $10^12$ or $10^{-9}$, \PGFPlots\ still uses \TeX-registers internally (the math parser of \PGF). If your axis interval is $[1234567.8, 1234567.9]$ or something like that, }.
-The option ``|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 |disabledatascaling| may lead to overflow or underflow in this context, so use it with care! Normally, the data scale transformation avoids this problem.}.
+The option ``|disabledatascaling|'' disables this data transformation. This has two consequences: first, coordinate expressions like \parg{{\normalfont\texttt{axis cs:}}x,y} have the same effect like \parg{x,y}, no re-scaling is applied. Second, coordinates are restricted to what \TeX\ can handle\footnote{Please note that the axis' scaling requires to compute $1/( x_\text{max} - x_{\text{min}} )$. The option |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).
\end{pgfplotskey}
@@ -3196,7 +4124,7 @@ During evaluation of the filter, the macro |\coordindex| contains the number of
\end{codeexample}
There is also a style key which simplifies selection by index, see below.
- \PGFPlots\ invokes the filter with argument |#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.
+ \PGFPlots\ invokes the filter with argument |#1| set to the input coordinate. For $x$-filters, this is the $x$-coordinate as it is specified to |\addplot|, for $y$-filters it is the $y$-coordinate.
If the corresponding axis is logarithmic, |#1| is the \emph{logarithm} of the coordinate as a real number, for example |#1=4.2341|.
@@ -3223,13 +4151,13 @@ There is also a style key which simplifies selection by index, see below.
\end{pgfplotskey}
\begin{pgfplotskey}{execute at begin plot=\marg{commands}}
-This axis option allows to invoke \marg{commands} at the beginning of each \lstinline!\addplot! command. The argument \marg{commands} can be any \TeX\ content.
+This axis option allows to invoke \marg{commands} at the beginning of each |\addplot| command. The argument \marg{commands} can be any \TeX\ content.
You may use this in conjunction with |xfilter=...| to reset any counters or whatever. An example would be to change every $4$th coordinate.
\end{pgfplotskey}
\begin{pgfplotskey}{execute at end plot=\marg{commands}}
-This axis option allows to invoke \marg{commands} after each \lstinline!\addplot! command. The argument \marg{commands} can be any \TeX\ content.
+This axis option allows to invoke \marg{commands} after each |\addplot| command. The argument \marg{commands} can be any \TeX\ content.
\end{pgfplotskey}
\begin{pgfplotscodekey}{before end axis}
@@ -3267,19 +4195,32 @@ Allows to insert \marg{commands} right after the end of the clipped drawing comm
\end{codeexample}
\end{pgfplotscodekey}
-\begin{pgfplotscodekey}{extra description}
-Allows to insert \marg{commands} after axis labels, titles and legends have been typeset.
+\begin{pgfplotskey}{clip marker paths=\mchoice{true,false} (initially false)}
+ The initial choice |clip marker paths=false| causes markers to be drawn \emph{after} the clipped region. Only their positions will be clipped. As a consequence, markers will be drawn completely, or not at all. The value |clip marker paths=true| is here for backwards compatibility: it does not introduce special marker treatment, so markers may be drawn partially if they are close to the clipping boundary\footnote{Please note that clipped marker paths may be slightly faster during \TeX\ compilation.}.
+\end{pgfplotskey}
-The code can thus use $(0,0)$ to access the lower left corner and $(1,1)$ to access the upper right one. It won't be clipped.
+\begin{pgfplotskey}{axis on top=\mchoice{true,false} (initially false)}
+ If set to |true|, axis lines, ticks, tick labels and grid lines will be drawn on top of plot graphics.
\begin{codeexample}[]
-\pgfplotsset{every axis/.append style={
- extra description/.code={
- \node at (0.5,0.5) {Center!};
- }}}
\begin{tikzpicture}
- \begin{axis}
- \addplot (\x,\x^2);
- \end{axis}
+ \begin{axis}[
+ axis on top=true,
+ axis x line=middle,
+ axis y line=middle]
+ \addplot+[fill] (\x,\x^3) \closedcycle;
+ \end{axis}
\end{tikzpicture}
\end{codeexample}
-\end{pgfplotscodekey}
+
+\begin{codeexample}[]
+\begin{tikzpicture}
+ \begin{axis}[
+ axis on top=false,
+ axis x line=middle,
+ axis y line=middle]
+ \addplot+[fill] (\x,\x^3) \closedcycle;
+ \end{axis}
+\end{tikzpicture}
+\end{codeexample}
+Please note that this feature does not affect plot marks. I think it looks unfamiliar if plot marks are crossed by axis descriptions.
+\end{pgfplotskey}