You can still make use of the trim
feature of TikZ: trim axis left
is just a shorthand for trim left=(current axis.west)
. Since you can name your axes, you can specify which axis to use for the trimming. In your case, you can trim the upper tikzpicture
using trim left=(plot1.west)
, name the small side plot plot2
, and trim the lower tikzpicture
using trim left=(plot1.west),trim right=(plot2.east)
. In this case, you're adding space on the right-hand side of the lower plot, so it appears to have the same width as the two upper plots.
\documentclass{scrartcl} % Dokumentenklasse
\usepackage[decimalsymbol=comma]{siunitx} % SI-Einheiten einheitlich setzen
\usepackage{pgfplots} % Import der Plots aus Matlab
\usepackage{tikz} % Import der Plots aus Matlab
\usetikzlibrary{plotmarks} % Import der Plots aus Matlab
\newlength\fheight % Plots aus Matlab immer gleich gross
\newlength\fwidth % Plots aus Matlab immer gleich gross
\setlength\fheight{6cm} % Plots aus Matlab immer gleich gross
\setlength\fwidth{8cm} % Plots aus Matlab immer gleich gross
\pgfplotsset{ % Komma statt Punkt als Dezimaltrennzeichen
x tick label style={/pgf/number format/use comma},
y tick label style={/pgf/number format/use comma}}
\listfiles
\begin{document}
My pgf version is: \pgfversion
\begin{figure}[!htb]
\centering
\begin{tikzpicture}[trim left=(plot1.west)]
\begin{axis}[
name=plot1,
scale only axis,
width=\fwidth,
height=\fheight,
xmin=0, xmax=2,
ymin=0, ymax=2,
xlabel={$x/\SI{}{\micro\meter}$},
ylabel={$y/\SI{}{\micro\meter}$},
axis on top]
% \addplot graphics [xmin=0, xmax=22,
% ymin=0, ymax=2] {../versuche/b_v610/step36_ende/ende_afm/detail_afm.eps};
\end{axis}
\hspace{10mm}
\begin{axis}[
name=plot2,
axis on top,
at=(plot1.right of south east), anchor=left of south west,
width=0.0675676\fwidth, height=1\fheight,
scale only axis,
xmin=0, xmax=1,
ymin=-30, ymax=50,
xtick=\empty, yticklabel pos=left,
ylabel={$h(x,y)/\SI{}{\nano\meter}$}]
% \addplot graphics [xmin=0, xmax=1, ymin=-30, ymax=50]
% {../versuche/b_v610/step36_ende/ende_afm/detail_afm-colorbar1.eps};
\end{axis}
\end{tikzpicture}
\end{figure}
\begin{figure}[!htb]
\centering
\begin{tikzpicture}[trim left=(plot1.south west),trim right=(plot2.south east)]
\begin{axis}[
name=plot1,
scale only axis,
width=\fwidth,
height=\fheight,
xmin=0, xmax=5,
ymin=0, ymax=5,
xlabel={$x$},
ylabel={$\sum_i x^2$},
axis on top]
% \addplot graphics [xmin=0, xmax=22,
% ymin=0, ymax=2] {../versuche/b_v610/step36_ende/ende_afm/detail_afm.eps};
\end{axis}
\end{tikzpicture}
\end{figure}
\end{document}
You could transform your data to milliseconds by using x filter/.code=\pgfmathparse{#1*1000}
, but a more elegant approach would be to use the units
library, which is loaded using \pgfplotslibrary{units}
in the preamble. You can then set x unit=s
to specify that the data is in seconds, set change x base=true
to allow pgfplots to transform the data, and then set x SI prefix=milli
to change the units to milliseconds.
\documentclass{article}
\usepackage{pgfplots}
\usepgfplotslibrary{units}
\begin{document}
\begin{tikzpicture}
\begin{axis}[xlabel=tijd,
ycomb, ymin=0, ymax=4, xmin=0.0248, xmax=0.0255,
enlarge y limits=false,
width=15cm, height=5cm,
tick align = outside,
grid = major,
%scaled x ticks = false,
yticklabels={X, 0, settings, macroblock, picture},
x unit=s,
change x base=true,
x SI prefix=milli
]
\addplot +[mark=none, ultra thick] table {
0.0249 2
0.0251 1
0.0254 1
};
\end{axis}
\end{tikzpicture}
\end{document}
Best Answer
The keys given in the
axis
options can also be set outside theaxis
environment by usingor, equivalently
For the example given in the answer this would become: