按高度对齐元素

按高度对齐元素

我创建了一个代表图例的 tikz 文件(用于不同的图)。我的文件如下所示:

% This file was created by matlab2tikz.
%
\definecolor{mycolor1}{rgb}{0.00000,0.70000,0.70000}%
\definecolor{mycolor2}{rgb}{0.98040,0.50200,0.44710}%
\definecolor{mycolor3}{rgb}{0.25490,0.41180,0.88240}%
%
\begin{tikzpicture}

\begin{axis}[%
width=\figurewidth,
height=0.046\figureheight,
at={(0\figurewidth,0\figureheight)},
scale only axis,
separate axis lines,
every outer x axis line/.append style={white!15!black},
every x tick label/.append style={font=\color{white!15!black}},
xmin=0,
xmax=381.99999293685,
xtick={\empty},
every outer y axis line/.append style={white!15!black},
every y tick label/.append style={font=\color{white!15!black}},
ymin=0,
ymax=10.0677080097919,
ytick={\empty},
hide axis,
axis on top,
title style={font=\titelfont},xlabel style={font=\axisfont},ylabel style={font=\axisfont},legend style={font=\legendfont},yticklabel style={font=\tickfont},xticklabel style={font=\tickfont},width=\figurewidth,height=\figureheight
]
\node[above right, align=left, text=black]
at (axis cs:50,2.01) {\scriptsize Engaged};
\node[above right, align=left, text=black]
at (axis cs:131,2.01) {\scriptsize Disengaged};
\node[above right, align=left, text=black]
at (axis cs:221,2.01) {\scriptsize Away from PC};
\node[above right, align=left, text=black]
at (axis cs:320,2.01) {\scriptsize External distraction};
\addplot [color=mycolor1,solid,line width=1.5pt,forget plot]
  table[row sep=crcr]{%
10  5.90104147723565\\
50  5.90104147723565\\
};
\addplot [color=mycolor1,line width=1.5pt,mark size=1.5pt,only marks,mark=*,mark options={solid},forget plot]
  table[row sep=crcr]{%
30  5.90104147723565\\
};
\addplot [color=mycolor2,dotted,line width=1.5pt,forget plot]
  table[row sep=crcr]{%
90.9999988824129    6.32291649567584\\
130.999998882413    6.32291649567584\\
};
\addplot [color=mycolor2,line width=1.5pt,mark size=1.5pt,only marks,mark=*,mark options={solid},forget plot]
  table[row sep=crcr]{%
110.999998882413    6.32291649567584\\
};
\addplot [color=red!20!lime,dashed,line width=1.5pt,forget plot]
  table[row sep=crcr]{%
180.999997362495    6.74479151411603\\
220.999997362494    6.74479151411603\\
};
\addplot [color=red!20!lime,line width=1.5pt,mark size=1.5pt,only marks,mark=*,mark options={solid},forget plot]
  table[row sep=crcr]{%
200.999997362494    6.74479151411603\\
};
\addplot [color=mycolor3,dashdotted,line width=1.5pt,forget plot]
  table[row sep=crcr]{%
279.999995440245    7.16666653255621\\
319.999995440245    7.16666653255621\\
};
\addplot [color=mycolor3,line width=1.5pt,mark size=1.5pt,only marks,mark=*,mark options={solid},forget plot]
  table[row sep=crcr]{%
299.999995440245    7.16666653255621\\
};
\end{axis}
\end{tikzpicture}%

如果我现在将其包含在我的 LaTeX 文档中,我会得到以下图像:

在此处输入图片描述

可以看出,线图和文本元素的高度并不完全对齐。尤其是最后一个元素太低了。

如何纠正这个问题?

相关内容