寻找时间表图

寻找时间表图

我怎样才能得到如下所示的图表?

在此处输入图片描述

答案1

一个tikz办法。

在此处输入图片描述

代码

\documentclass[border=1cm]{standalone}

\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}

\begin{tikzpicture}
  \foreach \x/\l in {0/0,1/10,2/20,3/30,4/40,5/50}{
  \foreach \y/\ll in {0/Network,1/Disk,2/CPU}{
  \draw[->] (-0.5,\y)node[left=2cm, anchor=west]{\ll} -- (6,\y);}
  \draw[dashed] (\x,0)node[below]{\l}--(\x,2);
  }
  \node[below] at(6,0){[\textup{ms}]};
  \draw[line width=3pt] (1,2)--(3,2);
  \draw[line width=3pt] (0,1)--(1,1);
  \draw[line width=3pt] (3,0)--(4,0);
\end{tikzpicture}

\end{document}

答案2

PSTtricks 解决方案:

\documentclass{article}

\usepackage{multido}
\usepackage{pstricks}
\usepackage{siunitx}

\def\timeline(#1)#2{%
  \psline{->}(!1.8 #1 0.52 sub)(!7.7 #1 0.52 sub)
  \rput[l](!0 #1 0.52 sub){#2}}
\def\timeInterval(#1,#2)#3{%
  \psline[linewidth = 3pt](!#1 2 add #2 0.52 sub)(!#1 #3 add 2 add #2 0.52 sub)}

\begin{document}

\begin{pspicture}(8,2.6)
  % top
  \timeline(3){CPU}
  \timeInterval(1,3){2}
  % middle
  \timeline(2){Disk}
  \timeInterval(0,2){1}
  % bottom
  \timeline(1){Network}
  \timeInterval(3,1){1}
  % time labels
  \multido{\r = 2+1, \i = 0+10}{6}{%
    \rput(\r,0.17){$\i$}
    \psline[linestyle = dotted, dotsep = 2pt](\r,0.48)(\r,2.48)}
  \rput(7.7,0.18){[\si{\ms}]}
\end{pspicture}

\end{document}

输出

相关内容