在 tikz 对象中组合矩阵和时间线

在 tikz 对象中组合矩阵和时间线

我用一个带有时间轴元素的矩阵创建了一个 tikzpicture。很难将时间戳适当地放置在时间轴的两端。有人有什么建议吗?谢谢!

编辑:Harish Kumar 指出了导致 \centering 不起作用的问题。谢谢 Kumar 先生。

输出如下:

latex tikz 的 pdf 输出

这里是代码(四边形很丑,但我是 tikz 新手):

\documentclass[journal]{IEEEtran}
\usepackage{tikz}
\usetikzlibrary{matrix}
\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}
\matrix(dict)[matrix of nodes,nodes={align=center,text width=0.17cm},
]{
    5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5\\
    \quad & \\
    5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5\\
    \quad & \\
    5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5\\
    \quad & \\
    5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5\\
    \quad & \\
    \quad & \quad & \quad & \quad & \quad & \quad & \quad & \quad & \quad & \quad & \quad & \quad & \quad & \quad & \quad & \quad & \quad & \quad & \quad & \quad & \quad \\
    \quad & \quad & \quad & \quad & \quad & \quad & \quad & \quad & \quad & \quad & \quad & \quad & \quad & \quad & \quad & \quad & \quad & \quad & \quad & \quad & \quad \\
    {\rotatebox{90}{0:00}} & & & & & & & & & & & & & & & & & & & & {\rotatebox{90}{1:45}} \\
};
\draw(dict-1-1.north west)--(dict-1-21.north east);
\draw(dict-1-1.south west)--(dict-1-21.south east);
\draw(dict-1-1.north west)--(dict-1-1.south west);
\draw(dict-1-4.north west)--(dict-1-4.south west);
\draw(dict-1-7.north west)--(dict-1-7.south west);
\draw(dict-1-10.north west)--(dict-1-10.south west);
\draw(dict-1-13.north west)--(dict-1-13.south west);
\draw(dict-1-16.north west)--(dict-1-16.south west);
\draw(dict-1-19.north west)--(dict-1-19.south west);
\draw(dict-1-21.north east)--(dict-1-21.south east);

\draw(dict-3-1.north west)--(dict-3-21.north east);
\draw(dict-3-1.south west)--(dict-3-21.south east);
\draw(dict-3-1.north west)--(dict-3-1.south west);
\draw(dict-3-7.north west)--(dict-3-7.south west);
\draw(dict-3-13.north west)--(dict-3-13.south west);
\draw(dict-3-19.north west)--(dict-3-19.south west);

\draw(dict-5-1.north west)--(dict-5-21.north east);
\draw(dict-5-1.south west)--(dict-5-21.south east);
\draw(dict-5-1.north west)--(dict-5-1.south west);
\draw(dict-5-10.north west)--(dict-5-10.south west);
\draw(dict-5-19.north west)--(dict-5-19.south west);

\draw(dict-7-1.north west)--(dict-7-21.north east);
\draw(dict-7-1.south west)--(dict-7-21.south east);
\draw(dict-7-1.north west)--(dict-7-1.south west);
\draw(dict-7-13.north west)--(dict-7-13.south west);

\draw(dict-9-1.south west)--(dict-9-21.south east);
\draw(dict-10-1.north west)--(dict-10-1.south west);
\draw(dict-10-21.north east)--(dict-10-21.south east);
\end{tikzpicture}
\caption{Market clearing frequency in five minute resolution}
\label{fig:market-timing}
\end{figure}
\end{document}

答案1

我刚刚对你的时间线标签进行了一些重叠

\documentclass[journal]{IEEEtran}
\usepackage{tikz}
\usetikzlibrary{matrix}
\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}
\matrix(dict)[matrix of nodes,nodes={align=center,text width=0.17cm},
]{
    5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5\\
    \quad & \\
    5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5\\
    \quad & \\
    5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5\\
    \quad & \\
    5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5 & 5\\
    \quad & \\
    \quad & \quad & \quad & \quad & \quad & \quad & \quad & \quad & \quad & \quad & \quad & \quad & \quad & \quad & \quad & \quad & \quad & \quad & \quad & \quad & \quad \\
    \quad & \quad & \quad & \quad & \quad & \quad & \quad & \quad & \quad & \quad & \quad & \quad & \quad & \quad & \quad & \quad & \quad & \quad & \quad & \quad & \quad \\
    {\llap{\rotatebox{90}{0:00}$\;$}} & & & & & & & & & & & & & & & & & & & & {\rlap{$\;$\rotatebox{90}{1:45}}} \\
};
\draw(dict-1-1.north west)--(dict-1-21.north east);
\draw(dict-1-1.south west)--(dict-1-21.south east);
\draw(dict-1-1.north west)--(dict-1-1.south west);
\draw(dict-1-4.north west)--(dict-1-4.south west);
\draw(dict-1-7.north west)--(dict-1-7.south west);
\draw(dict-1-10.north west)--(dict-1-10.south west);
\draw(dict-1-13.north west)--(dict-1-13.south west);
\draw(dict-1-16.north west)--(dict-1-16.south west);
\draw(dict-1-19.north west)--(dict-1-19.south west);
\draw(dict-1-21.north east)--(dict-1-21.south east);

\draw(dict-3-1.north west)--(dict-3-21.north east);
\draw(dict-3-1.south west)--(dict-3-21.south east);
\draw(dict-3-1.north west)--(dict-3-1.south west);
\draw(dict-3-7.north west)--(dict-3-7.south west);
\draw(dict-3-13.north west)--(dict-3-13.south west);
\draw(dict-3-19.north west)--(dict-3-19.south west);

\draw(dict-5-1.north west)--(dict-5-21.north east);
\draw(dict-5-1.south west)--(dict-5-21.south east);
\draw(dict-5-1.north west)--(dict-5-1.south west);
\draw(dict-5-10.north west)--(dict-5-10.south west);
\draw(dict-5-19.north west)--(dict-5-19.south west);

\draw(dict-7-1.north west)--(dict-7-21.north east);
\draw(dict-7-1.south west)--(dict-7-21.south east);
\draw(dict-7-1.north west)--(dict-7-1.south west);
\draw(dict-7-13.north west)--(dict-7-13.south west);

\draw(dict-9-1.south west)--(dict-9-21.south east);
\draw(dict-10-1.north west)--(dict-10-1.south west);
\draw(dict-10-21.north east)--(dict-10-21.south east);
\end{tikzpicture}
\caption{Market clearing frequency in five minute resolution}
\label{fig:market-timing}
\end{figure}
\end{document}

在此处输入图片描述

相关内容