summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/pgfplots/pgfplots.examples.tex
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/doc/latex/pgfplots/pgfplots.examples.tex')
-rw-r--r--Master/texmf-dist/doc/latex/pgfplots/pgfplots.examples.tex899
1 files changed, 899 insertions, 0 deletions
diff --git a/Master/texmf-dist/doc/latex/pgfplots/pgfplots.examples.tex b/Master/texmf-dist/doc/latex/pgfplots/pgfplots.examples.tex
new file mode 100644
index 00000000000..fb3e8706368
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/pgfplots/pgfplots.examples.tex
@@ -0,0 +1,899 @@
+% main=manual.tex
+
+
+\section{More examples}
+This section contains a catalogue of different \PGFPlots\ features by example.
+\label{sec:examples}%
+\begingroup
+\subsection{Legend position and appearance}
+\subsubsection{Legend in the lower left corner}
+\begin{lstlisting}
+\tikzstyle{every axis legend}+=
+ [at={(0.03,0.03)},anchor=south west]%
+\begin{tikzpicture}
+ \begin{loglogaxis}[
+ xlabel={\textsc{Dof}},
+ ylabel={$L_2$ Error}
+ ]
+ \addplot plot coordinates {
+ (5, 8.312e-02)
+ (17, 2.547e-02)
+ (49, 7.407e-03)
+ (129, 2.102e-03)
+ (321, 5.874e-04)
+ (769, 1.623e-04)
+ (1793, 4.442e-05)
+ (4097, 1.207e-05)
+ (9217, 3.261e-06)
+ };
+
+ ....
+
+ \legend{$d=2$\\$d=3$\\$d=4$\\$d=5$\\$d=6$\\}
+ \end{loglogaxis}
+\end{tikzpicture}
+\end{lstlisting}
+\def\plots{%
+ \addplot plot coordinates {
+ (5, 8.312e-02)
+ (17, 2.547e-02)
+ (49, 7.407e-03)
+ (129, 2.102e-03)
+ (321, 5.874e-04)
+ (769, 1.623e-04)
+ (1793, 4.442e-05)
+ (4097, 1.207e-05)
+ (9217, 3.261e-06)
+ };
+
+ \addplot plot coordinates {
+ (7, 8.472e-02)
+ (31, 3.044e-02)
+ (111, 1.022e-02)
+ (351, 3.303e-03)
+ (1023, 1.039e-03)
+ (2815, 3.196e-04)
+ (7423, 9.658e-05)
+ (18943, 2.873e-05)
+ (47103, 8.437e-06)
+ };
+
+ \addplot plot coordinates {
+ (9, 7.881e-02)
+ (49, 3.243e-02)
+ (209, 1.232e-02)
+ (769, 4.454e-03)
+ (2561, 1.551e-03)
+ (7937, 5.236e-04)
+ (23297, 1.723e-04)
+ (65537, 5.545e-05)
+ (178177, 1.751e-05)
+ };
+
+ \addplot plot coordinates {
+ (11, 6.887e-02)
+ (71, 3.177e-02)
+ (351, 1.341e-02)
+ (1471, 5.334e-03)
+ (5503, 2.027e-03)
+ (18943, 7.415e-04)
+ (61183, 2.628e-04)
+ (187903, 9.063e-05)
+ (553983, 3.053e-05)
+ };
+
+ \addplot plot coordinates {
+ (13, 5.755e-02)
+ (97, 2.925e-02)
+ (545, 1.351e-02)
+ (2561, 5.842e-03)
+ (10625, 2.397e-03)
+ (40193, 9.414e-04)
+ (141569, 3.564e-04)
+ (471041, 1.308e-04)
+ (1496065, 4.670e-05)
+ };
+ \legend{$d=2$\\$d=3$\\$d=4$\\$d=5$\\$d=6$\\}
+}%
+{%
+\tikzstyle{every axis legend}+=
+ [at={(0.03,0.03)},anchor=south west]%
+\begin{center}
+\begin{tikzpicture}
+ \begin{loglogaxis}[
+ xlabel={\textsc{Dof}},
+ ylabel={$L_2$ Error}
+ ]
+ \plots
+ \end{loglogaxis}
+\end{tikzpicture}
+\end{center}
+}
+
+\subsubsection{Horizontal Legends}
+\begin{lstlisting}
+\tikzstyle{every axis legend}+=
+ [at={(0.5,0.98)},anchor=north]%
+\begin{tikzpicture}
+ \begin{loglogaxis}[
+ legend columns=2,
+ xlabel={\textsc{Dof}},
+ ylabel={$L_2$ Error}
+ ]
+ \addplot plot coordinates {
+ (5, 8.312e-02)
+ (17, 2.547e-02)
+ (49, 7.407e-03)
+ (129, 2.102e-03)
+ (321, 5.874e-04)
+ (769, 1.623e-04)
+ (1793, 4.442e-05)
+ (4097, 1.207e-05)
+ (9217, 3.261e-06)
+ };
+
+ ....
+
+ \legend{$d=2$\\$d=3$\\$d=4$\\$d=5$\\$d=6$\\}
+ \end{loglogaxis}
+\end{tikzpicture}
+\end{lstlisting}
+{%
+\tikzstyle{every axis legend}+=
+ [at={(0.5,0.98)},anchor=north]%
+\begin{center}
+\begin{tikzpicture}
+ \begin{loglogaxis}[
+ legend columns=2,
+ xlabel={\textsc{Dof}},
+ ylabel={$L_2$ Error}
+ ]
+ \plots
+ \end{loglogaxis}
+\end{tikzpicture}
+\end{center}
+}
+
+\subsubsection{Horizontal Legends (2)}
+\begin{lstlisting}
+\tikzstyle{every axis legend}+=
+ [at={(0.5,-0.2)},anchor=north]%
+\begin{tikzpicture}
+ \begin{loglogaxis}[
+ legend columns=-1,
+ xlabel={\textsc{Dof}},
+ ylabel={$L_2$ Error}
+ ]
+ \addplot plot coordinates {
+ (5, 8.312e-02)
+ (17, 2.547e-02)
+ (49, 7.407e-03)
+ (129, 2.102e-03)
+ (321, 5.874e-04)
+ (769, 1.623e-04)
+ (1793, 4.442e-05)
+ (4097, 1.207e-05)
+ (9217, 3.261e-06)
+ };
+
+ ....
+
+ \legend{$d=2$\\$d=3$\\$d=4$\\$d=5$\\$d=6$\\}
+ \end{loglogaxis}
+\end{tikzpicture}
+\end{lstlisting}
+{%
+\tikzstyle{every axis legend}+=
+ [at={(0.5,-0.2)},anchor=north]%
+\begin{center}
+\begin{tikzpicture}
+ \begin{loglogaxis}[
+ legend columns=-1,
+ xlabel={\textsc{Dof}},
+ ylabel={$L_2$ Error}
+ ]
+ \plots
+ \end{loglogaxis}
+\end{tikzpicture}
+\end{center}
+}
+
+\subsubsection{Modifying legend spacing}
+\label{sec:legendexamples:cols}%
+\begin{lstlisting}
+\tikzstyle{every axis legend}+=
+ [at={(0.5,1.02)},anchor=south,inner sep=0pt]%
+\begin{tikzpicture}
+ \begin{loglogaxis}[
+ legend columns=-1,
+ xlabel={\textsc{Dof}},
+ ylabel={$L_2$ Error}
+ ]
+ \addplot plot coordinates {
+ (5, 8.312e-02)
+ (17, 2.547e-02)
+ (49, 7.407e-03)
+ (129, 2.102e-03)
+ (321, 5.874e-04)
+ (769, 1.623e-04)
+ (1793, 4.442e-05)
+ (4097, 1.207e-05)
+ (9217, 3.261e-06)
+ };
+
+ ....
+
+ \legend{$d=2$\\$d=3$\\$d=4$\\$d=5$\\$d=6$\\}
+ \end{loglogaxis}
+\end{tikzpicture}
+\end{lstlisting}
+{%
+\tikzstyle{every axis legend}+=
+ [at={(0.5,0.98)},anchor=north,inner sep=0pt]%
+\begin{center}
+\begin{tikzpicture}
+ \begin{loglogaxis}[
+ legend columns=-1,
+ xlabel={\textsc{Dof}},
+ ylabel={$L_2$ Error}
+ ]
+ \plots
+ \end{loglogaxis}
+\end{tikzpicture}
+\end{center}
+}
+
+\subsubsection{Modifying legend's small plots}
+\label{sec:legendexamples:plotpos}%
+\begin{lstlisting}
+\begin{tikzpicture}
+ \begin{loglogaxis}[
+ legend plot pos=right,
+ xlabel={\textsc{Dof}},
+ ylabel={$L_2$ Error}
+ ]
+ \addplot plot coordinates {
+ (5, 8.312e-02)
+ (17, 2.547e-02)
+ (49, 7.407e-03)
+ (129, 2.102e-03)
+ (321, 5.874e-04)
+ (769, 1.623e-04)
+ (1793, 4.442e-05)
+ (4097, 1.207e-05)
+ (9217, 3.261e-06)
+ };
+
+ ....
+
+ \legend{$d=2$\\$d=3$\\$d=4$\\$d=5$\\$d=6$\\}
+ \end{loglogaxis}
+\end{tikzpicture}
+\end{lstlisting}
+{%
+\begin{center}
+\begin{tikzpicture}
+ \begin{loglogaxis}[
+ legend plot pos=right,
+ xlabel={\textsc{Dof}},
+ ylabel={$L_2$ Error}
+ ]
+ \plots
+ \end{loglogaxis}
+\end{tikzpicture}
+\end{center}
+}
+
+\subsection{Font size and line width}
+\begin{lstlisting}
+\tikzstyle{every axis legend}+=%
+ [at={(0.03,0.03)},anchor=south west]%
+\tikzstyle{every tick}+=[line width=0.6pt]%
+\begin{tikzpicture}[font=\large,line width=1pt]
+ \begin{loglogaxis}[
+ xlabel={\textsc{Dof}},
+ ylabel={$L_2$ Error}
+ ]
+ \addplot ....
+ ...
+ \end{loglogaxis}
+\end{tikzpicture}
+\end{lstlisting}
+
+{%
+\tikzstyle{every axis legend}+=
+ [at={(0.03,0.03)},anchor=south west]%
+\tikzstyle{every tick}+=[line width=0.6pt]
+\begin{center}
+\begin{tikzpicture}[font=\large,line width=1pt]
+ \begin{loglogaxis}[
+ xlabel={\textsc{Dof}},
+ ylabel={$L_2$ Error}
+ ]
+ \plots
+ \end{loglogaxis}
+\end{tikzpicture}
+\end{center}
+}%
+
+\subsection{Changing line specifications}
+\subsubsection{Using another, predefined list}
+{%
+\begin{lstlisting}
+\listcopy\blackwhiteplotspeclist\to\autoplotspeclist%
+\begin{tikzpicture}
+ \begin{loglogaxis}[
+ xlabel={\textsc{Dof}},
+ ylabel={$L_2$ Error}
+ ]
+ ...
+ \end{loglogaxis}
+\end{tikzpicture}
+\end{lstlisting}
+
+\listcopy\blackwhiteplotspeclist\to\autoplotspeclist%
+\begin{center}
+\begin{tikzpicture}
+ \begin{loglogaxis}[
+ xlabel={\textsc{Dof}},
+ ylabel={$L_2$ Error}
+ ]
+ \plots
+ \end{loglogaxis}
+\end{tikzpicture}
+\end{center}
+
+\subsubsection{Defining new lists}
+\begin{lstlisting}
+% will cycle through these three elements:
+\listnew{\autoplotspeclist}{%
+ red,dotted,mark=-,mark options={solid}\\%
+ black,dashed,mark=pentagon,mark options={solid}\\%
+ mark options={fill=blue!40},mark=diamond*,blue\\%
+}%
+\tikzstyle{every axis legend}+=%
+ [at={(1.03,1)},anchor=north west]%
+\begin{tikzpicture}
+ \begin{loglogaxis}[
+ xlabel={\textsc{Dof}},
+ ylabel={$L_2$ Error}
+ ]
+ ...
+ \end{loglogaxis}
+\end{tikzpicture}
+\end{lstlisting}
+
+\listnew{\autoplotspeclist}{%
+ red,dotted,mark=-,mark options={solid}\\%
+ black,dashed,mark=pentagon,mark options={solid}\\%
+ mark options={fill=blue!40},mark=diamond*,blue\\%
+}%
+\tikzstyle{every axis legend}+=%
+ [at={(1.03,1)},anchor=north west]%
+\begin{center}
+\begin{tikzpicture}
+ \begin{loglogaxis}[
+ xlabel={\textsc{Dof}},
+ ylabel={$L_2$ Error}
+ ]
+ \plots
+ \end{loglogaxis}
+\end{tikzpicture}
+\end{center}
+}%
+
+\subsection{Changing the ticks}
+\subsubsection{Placing ticks at $10^i$}
+\begin{lstlisting}
+\begin{tikzpicture}
+ \begin{loglogaxis}[
+ xtickten={0,2,3,4,6,...,10},% place tickmarks at 10^0, 10^2,...
+ ytickten={-6,-4,...,2},
+ xlabel={\textsc{Dof}},
+ ylabel={$L_2$ Error}
+ ]
+ ....
+ \end{loglogaxis}
+\end{tikzpicture}
+\end{lstlisting}
+
+\begin{center}
+\begin{tikzpicture}
+ \begin{loglogaxis}[
+ xtickten={0,2,3,4,6,...,10},
+ ytickten={-6,-4,...,2},
+ xlabel={\textsc{Dof}},
+ ylabel={$L_2$ Error}
+ ]
+ \plots
+ \end{loglogaxis}
+\end{tikzpicture}
+\end{center}
+
+\subsubsection{Placing ticks anywhere}
+\begin{lstlisting}
+\begin{tikzpicture}
+ \begin{loglogaxis}[
+ xtick={12,9897,1468864}
+ xlabel={\textsc{Dof}},
+ ylabel={$L_2$ Error}
+ ]
+ ....
+ \end{loglogaxis}
+\end{tikzpicture}
+\end{lstlisting}
+
+\begin{center}
+\begin{tikzpicture}
+ \begin{loglogaxis}[
+ xtick={12,9897,1468864},%2.5,9.2,14.2},
+ xlabel={\textsc{Dof}},
+ ylabel={$L_2$ Error}
+ ]
+ \plots
+ \end{loglogaxis}
+\end{tikzpicture}
+\end{center}
+
+\subsection{Annotating plots}
+\label{sec:annot:plot}%
+\subsubsection{Example: Placing Data Cursors}
+\begin{lstlisting}
+\tikzstyle{every pin}=[fill=white,draw=black,font=\footnotesize]
+\begin{tikzpicture}
+ \begin{loglogaxis}[
+ xlabel={\textsc{Dof}},
+ ylabel={$L_2$ Error}
+ ]
+
+ ....
+
+ \addplot plot coordinates {
+ (11, 6.887e-02)
+ (71, 3.177e-02)
+ (351, 1.341e-02)
+ (1471, 5.334e-03)
+ (5503, 2.027e-03)
+ (18943, 7.415e-04)
+ (61183, 2.628e-04)
+ (187903, 9.063e-05)
+ (553983, 3.053e-05)
+ };
+ ...
+
+ \axispath\node[coordinate,pin=above:Bad!]
+ at (axis cs:5503,2.027e-03) {};
+ \axispath\node[coordinate,pin=above right:Good!]
+ at (axis cs:187903,9.063e-05) {};
+ \end{loglogaxis}
+\end{tikzpicture}
+\end{lstlisting}
+\begin{center}
+{
+\tikzstyle{every pin}=[fill=white,draw=black,font=\footnotesize]
+\begin{tikzpicture}
+ \begin{loglogaxis}[
+ xlabel={\textsc{Dof}},
+ ylabel={$L_2$ Error}
+ ]
+ \plots
+
+ \axispath\node[coordinate,pin=above:Bad!]
+ at (axis cs:5503,2.027e-03) {};
+ \axispath\node[coordinate,pin=above right:Good!]
+ at (axis cs:187903,9.063e-05) {};
+ \end{loglogaxis}
+\end{tikzpicture}
+}
+\end{center}
+
+One remark: the \lstinline!\axispath! prefix is necessary because neither axis nor plots will be drawn until the $x$- and $y$-limits have been determined. All drawing commands are postponed until \lstinline!\end{axis}! (unless you explicitly provide the options \lstinline!xmin!, \lstinline!xmax!, \lstinline!ymin! and \lstinline!ymax!).
+
+\subsubsection{Example: Slopes of line segments}
+\begin{lstlisting}
+\begin{tikzpicture}
+ \begin{loglogaxis}[
+ xlabel=\textsc{Dof},
+ ylabel=$L_2$ Error
+ ]
+ \axispath\draw
+ (axis cs:1793,4.442e-05)
+ |- (axis cs:4097,1.207e-05)
+ node[near start,left] {$\frac{dy}{dx} = -1.58$};
+
+ \addplot plot coordinates {
+ (5, 8.312e-02)
+ (17, 2.547e-02)
+ (49, 7.407e-03)
+ (129, 2.102e-03)
+ (321, 5.874e-04)
+ (769, 1.623e-04)
+ (1793, 4.442e-05)
+ (4097, 1.207e-05)
+ (9217, 3.261e-06)
+ };
+ ...
+ \end{loglogaxis}
+\end{tikzpicture}
+\end{lstlisting}
+\begin{center}
+\begin{tikzpicture}
+ \begin{loglogaxis}[
+ xlabel=\textsc{Dof},
+ ylabel=$L_2$ Error
+ ]
+ \axispath\draw
+ (axis cs:1793,4.442e-05)
+ |- (axis cs:4097,1.207e-05)
+ node[near start,left] {$\frac{dy}{dx} = -1.58$};
+ \plots
+
+ \end{loglogaxis}
+\end{tikzpicture}
+\end{center}
+
+\subsection{Vertical alignment with the \texttt{baseline} option}
+\label{sec:align}%
+The default axis anchor is \texttt{south west}, which means that the picture coordinate $(0,0)$ is the lower left corner of the axis. As a consequence, the \Tikz\ option ``\texttt{baseline}'' allows vertical alignment of adjacent plots, see figure~\ref{fig:baseline:example} for an example.
+\begin{figure}
+ \centering
+ \noindent
+ \lstinline!\begin{tikzpicture}...\end{tikzpicture}!:\par
+ \noindent
+ \begin{tikzpicture}%
+ \begin{axis}[width=0.4\linewidth,xlabel=A normal sized $x$ label]
+ \addplot[smooth,blue,mark=*] plot coordinates {
+ (-1, 1)
+ (-0.75, 0.5625)
+ (-0.5, 0.25)
+ (-0.25, 0.0625)
+ (0, 0)
+ (0.25, 0.0625)
+ (0.5, 0.25)
+ (0.75, 0.5625)
+ (1, 1)
+ };
+ \end{axis}
+ \end{tikzpicture}%
+ \hspace{0.15cm}
+ \begin{tikzpicture}%
+ \begin{axis}[width=0.4\linewidth,xlabel={xlabel: $\displaystyle \sum_{i=0}^N n_i $ }]
+ \addplot[smooth,blue,mark=*] plot coordinates {
+ (-1, 1)
+ (-0.75, 0.5625)
+ (-0.5, 0.25)
+ (-0.25, 0.0625)
+ (0, 0)
+ (0.25, 0.0625)
+ (0.5, 0.25)
+ (0.75, 0.5625)
+ (1, 1)
+ };
+ \end{axis}
+ \end{tikzpicture}
+ \hfill
+ \vskip 0.3cm%
+ \noindent
+ \lstinline!\begin{tikzpicture}[baseline]...\end{tikzpicture}!:\par
+ \noindent
+ \begin{tikzpicture}[baseline]%
+ \begin{axis}[width=0.4\linewidth,xlabel=A normal sized $x$ label]
+ \addplot[smooth,blue,mark=*] plot coordinates {
+ (-1, 1)
+ (-0.75, 0.5625)
+ (-0.5, 0.25)
+ (-0.25, 0.0625)
+ (0, 0)
+ (0.25, 0.0625)
+ (0.5, 0.25)
+ (0.75, 0.5625)
+ (1, 1)
+ };
+ \end{axis}
+ \end{tikzpicture}%
+ \hspace{0.15cm}
+ \begin{tikzpicture}[baseline]%
+ \begin{axis}[width=0.4\linewidth,xlabel={xlabel: $\displaystyle \sum_{i=0}^N n_i $ }]
+ \addplot[smooth,blue,mark=*] plot coordinates {
+ (-1, 1)
+ (-0.75, 0.5625)
+ (-0.5, 0.25)
+ (-0.25, 0.0625)
+ (0, 0)
+ (0.25, 0.0625)
+ (0.5, 0.25)
+ (0.75, 0.5625)
+ (1, 1)
+ };
+ \end{axis}
+ \end{tikzpicture}
+ \hfill
+
+ \caption{An example of the \Tikz-``\texttt{baseline}'' option for vertical alignment. Top row: without ``\texttt{baseline}'', bottom row: with ``\texttt{baseline}''.}
+ \label{fig:baseline:example}
+\end{figure}
+
+\subsection{Horizontal Alignment}
+{%
+\label{sec:halign}%
+The last subsection used the \texttt{baseline}-option to allow \emph{vertical} alignment of plots. You can also apply \emph{horizontal} alignment, if you place multiple \texttt{axes} into a single \texttt{tikzpicture} and use the `\texttt{anchor}'-option:
+\def\plots{
+\addplot[red,only marks,mark options={fill=red,scale=0.8},mark=*] plot coordinates {
+ (0.190600, 0.860900)
+ (0.194400, 0.908000)
+ (0.179900, 0.140700)
+ (0.212400, 0.294200)
+ (0.218900, 0.779100)
+ (0.201700, 0.388400)
+ (0.209100, 0.679900)
+ (0.196200, 0.470800)
+ (0.199900, 0.812700)
+ (0.199300, 0.850500)
+ (0.204300, 0.980300)
+ (0.209500, 0.953000)
+ (0.176200, 0.145300)
+ (0.207400, 0.351900)
+ (0.199000, 0.304500)
+ (0.202200, 0.256300)
+ (0.197000, 0.744300)
+ (0.181100, 0.998900)
+ (0.193400, 0.554900)
+ (0.218300, 0.506500)
+ (0.193800, 0.201000)
+ (0.208100, 0.531900)
+ (0.204100, 0.635500)
+ (0.217000, 0.069800)
+ (0.196100, 0.710300)
+ (0.198900, 0.440900)
+ (0.213000, 0.591900)
+ (0.206000, 0.030700)
+ (0.186000, 0.395900)
+ (0.206500, 0.082500)
+ (0.195500, 0.672000)
+ (0.221400, -0.013500)
+ (0.202300, 0.222300)
+ (0.193300, 0.959700)
+};
+\addplot[black,only marks,mark options={fill=black,scale=0.8},mark=square*] plot coordinates {
+ (0.005300, 0.369500)
+ (-0.016100, 0.610000)
+ (-0.007400, 0.252100)
+ (0.002900, 0.699600)
+ (0.010900, 0.232000)
+ (-0.014100, 0.152400)
+ (-0.008000, -0.003100)
+ (-0.009100, 0.639900)
+ (-0.008700, 0.125800)
+ (-0.003700, 0.897400)
+ (0.009600, 0.432200)
+ (-0.009100, 0.770800)
+ (-0.030300, 0.974200)
+ (-0.004000, 0.675900)
+ (-0.002100, 0.089500)
+ (0.003300, 0.319700)
+ (0.006100, 0.863300)
+ (0.000600, 0.263700)
+ (-0.008900, 0.471500)
+ (0.016000, 0.505700)
+ (0.000000, 0.602600)
+ (-0.012300, 0.404400)
+ (-0.007000, 0.911900)
+ (0.006700, 0.747200)
+ (0.009000, 0.825300)
+ (-0.001500, 0.534400)
+ (-0.020600, 0.336300)
+ (0.012600, 0.039800)
+ (0.011600, 0.944100)
+ (-0.003600, 0.068000)
+ (-0.022400, 0.575400)
+ (-0.002900, 0.184500)
+};
+\addplot[blue] plot coordinates {
+ (0.093947, -0.011481)
+ (0.101957, 0.494273)
+ (0.109967, 1.000027)
+};
+}%
+\begin{lstlisting}
+\begin{tikzpicture}
+ \begin{axis}[width=4cm,scale only axis]
+ \addplot[red,only marks,mark options={fill=red,scale=0.8},mark=*] plot coordinates {
+ (0.190600, 0.860900)
+ (0.194400, 0.908000)
+ (0.179900, 0.140700)
+ (0.212400, 0.294200)
+ ....
+ (0.202300, 0.222300)
+ (0.193300, 0.959700)
+ };
+ \addplot[black,only marks,mark options={fill=black,scale=0.8},mark=square*] plot coordinates {
+ (0.005300, 0.369500)
+ (-0.016100, 0.610000)
+ (-0.007400, 0.252100)
+ (0.002900, 0.699600)
+ (0.010900, 0.232000)
+ ....
+ (-0.003600, 0.068000)
+ (-0.022400, 0.575400)
+ (-0.002900, 0.184500)
+ };
+ \addplot[blue] plot coordinates {
+ (0.093947, -0.011481)
+ (0.101957, 0.494273)
+ (0.109967, 1.000027)
+ };
+ \end{axis}
+
+ \draw[thick,gray,->]
+ (0,0) -- (0cm,-0.6cm)
+ node[black,midway,left] {0.6cm$\to$};
+
+ \begin{scope}[yshift=-0.6cm]
+ \begin{axis}[%
+ anchor=north west,
+ width=4cm,scale only axis,
+ height=0.8cm,
+ ytick=\empty
+ ]
+
+ \addplot[red,only marks,mark options={fill=red,scale=0.8},mark=*] plot coordinates {
+ (0.968555, 0)
+ (0.030884, 0)
+ ...
+ (0.468750, 0)
+ (0, 0)
+ };
+ \addplot[black,only marks,mark options={fill=black,scale=0.8},mark=square*] plot coordinates {
+ (0.367188, 0)
+ (0.312500, 0)
+ ...
+ (0.125000, 0)
+ (0.156250, 0)
+ };
+ \end{axis}
+ \end{scope}
+\end{tikzpicture}
+\end{lstlisting}
+The result of this alignment is shown in figure~\ref{fig:halign}.
+
+\begin{figure}
+{\centering
+\begin{minipage}[t]{4.4cm}%
+\vspace{0pt}%
+\centering
+\begin{tikzpicture}
+ \begin{axis}[width=4cm,scale only axis]
+ \plots
+ \end{axis}
+\end{tikzpicture}
+
+\begin{tikzpicture}
+ \begin{axis}[%
+ width=4cm,scale only axis,
+ height=0.8cm,
+ ytick=\empty
+ ]
+
+ \addplot[red,only marks,mark options={fill=red,scale=0.8},mark=*] plot coordinates {
+ (0.968555, 0)
+ (0.030884, 0)
+ (0.750000, 0)
+ (0.468750, 0)
+ (1.000000, 0)
+ (0.030176, 0)
+ (0.750000, 0)
+ (0.468750, 0)
+ (0, 0)
+ };
+ \addplot[black,only marks,mark options={fill=black,scale=0.8},mark=square*] plot coordinates {
+ (0.367188, 0)
+ (0.312500, 0)
+ (0.136719, 0)
+ (0.828125, 0)
+ (0.656250, 0)
+ (0.343750, 0)
+ (0.125000, 0)
+ (0.156250, 0)
+ };
+ \end{axis}
+\end{tikzpicture}
+\end{minipage}
+\hspace{1cm}
+\begin{minipage}[t]{4.4cm}%
+\vspace{0pt}%
+\centering
+\begin{tikzpicture}
+ \begin{axis}[width=4cm,scale only axis]
+ \plots
+ \end{axis}
+
+ \draw[thick,gray,->]
+ (0,0) -- (0cm,-0.6cm)
+ node[black,midway,left] {0.6cm$\to$};
+
+ \begin{scope}[yshift=-0.6cm]
+ \begin{axis}[%
+ anchor=north west,
+ width=4cm,scale only axis,
+ height=0.8cm,
+ ytick=\empty
+ ]
+
+ \addplot[red,only marks,mark options={fill=red,scale=0.8},mark=*] plot coordinates {
+ (0.968555, 0)
+ (0.030884, 0)
+ (0.750000, 0)
+ (0.468750, 0)
+ (1.000000, 0)
+ (0.030176, 0)
+ (0.750000, 0)
+ (0.468750, 0)
+ (0, 0)
+ };
+ \addplot[black,only marks,mark options={fill=black,scale=0.8},mark=square*] plot coordinates {
+ (0.367188, 0)
+ (0.312500, 0)
+ (0.136719, 0)
+ (0.828125, 0)
+ (0.656250, 0)
+ (0.343750, 0)
+ (0.125000, 0)
+ (0.156250, 0)
+ };
+ \end{axis}
+ \end{scope}
+\end{tikzpicture}
+\end{minipage}
+
+}
+ \caption{Demonstration of horizontal alignment with the `\texttt{anchor}' option. Left: two \texttt{tikzpicture}s placed above each other; right: one \texttt{tikzpicture} with horizontal alignment using the `\texttt{anchor}'-option. The source code is in the text.}
+ \label{fig:halign}
+\end{figure}
+}
+
+\subsection{Gridlines}
+\label{sec:gridlines}%
+\begin{lstlisting}
+\begin{tikzpicture}
+ \begin{loglogaxis}[
+ xlabel={\textsc{Dof}},
+ ylabel={$L_2$ Error},
+ grid=major
+ ]
+ ...
+ \end{loglogaxis}
+\end{tikzpicture}
+
+\begin{tikzpicture}
+ \begin{loglogaxis}[
+ xlabel={\textsc{Dof}},
+ ylabel={$L_2$ Error},
+ grid=both
+ ]
+ ...
+ \end{loglogaxis}
+\end{tikzpicture}
+\end{lstlisting}
+\begin{center}
+\begin{tikzpicture}
+ \begin{loglogaxis}[
+ xlabel={\textsc{Dof}},
+ ylabel={$L_2$ Error},
+ grid=major
+ ]
+ \plots
+ \end{loglogaxis}
+\end{tikzpicture}
+\hfill
+\begin{tikzpicture}
+ \begin{loglogaxis}[
+ xlabel={\textsc{Dof}},
+ ylabel={$L_2$ Error},
+ grid=both
+ ]
+ \plots
+ \end{loglogaxis}
+\end{tikzpicture}
+\end{center}
+
+\endgroup