tikz 图表时间线

tikz 图表时间线

我正在尝试使用 tikz 制作下图,但在绘制尖峰方面遇到了问题。如能提供任何帮助,我将不胜感激。提前致谢!

在此处输入图片描述

答案1

用过的比基·特隆回答作为起点(而不是缺少OP MWE):

\documentclass[11pt, tikz, margin=3mm]{standalone}

\begin{document}
   \begin{tikzpicture}[xscale=1.2,
   tick/.style = {inner sep=2pt, text height=1.2ex, font=\footnotesize}
                        ]
\draw[thick] (0,2) node[left] {A} 
                   -- ++ (2.3,0) -- ++ (0.1,0.2) -- ++ (0.2,-0.4) -- ++ (0.1,0.2) 
                   -- ++ (0.6,0) -- ++ (0.1,0.2) -- ++ (0.2,-0.4) -- ++ (0.1,0.2)  
                   -- ++ (2.3,0) node[right]{CP};
\foreach \i [count=\j from 0] in {0, 1, 2, s, n-2, n-1, n}
{
\ifnum\j<1
    \draw   (\j,2.15) node[tick,above] {$C_0$}
                         -- ++ (0,-3mm) node[tick,below] {$\i$};
\else
   \draw    (\j,2.15) -- ++ (0,-3mm) node[tick,below] {$\i$};
\fi
}
%
\draw[thick] (0,0) node[left] {A}
                   -- ++ (2.3,0) -- ++ (0.1,0.2) -- ++ (0.2,-0.4) -- ++ (0.1,0.2)
                   -- ++ (0.6,0) -- ++ (0.1,0.2) -- ++ (0.2,-0.4) -- ++ (0.1,0.2)
                   -- ++ (2.3,0) node[right]{CP};
\foreach \i [count=\j from 0] in {0, 1, 2, s, n-2, n-1, n}
{
\ifnum\j<1
    \draw   (\j,0.15) -- ++ (0,-3mm) node[tick,below] {$\i$};
\else
   \draw    (\j,0.15) node[tick,above] {$a$}
                         -- ++ (0,-3mm) node[tick,below] {$\i$};
\fi
}
    \end{tikzpicture}
\end{document}

在此处输入图片描述

答案2

\documentclass[11pt]{article}
\usepackage{tikz}

\usetikzlibrary{arrows,positioning, calc,lindenmayersystems,decorations.pathmorphing,intersections,decorations.text}

\begin{document}
     \begin{center}
   \begin{tikzpicture}

   \draw[thick] (0,3)node[anchor=east]{A} --(2.2,3);
   \draw[thick] (2.2,3) --(2.5,3.2)--(3,2.8)--(3.2,3)--(4.2,3)--(4.5,3.2)--(5,2.8)--(5.2,3)--(8,3)node[anchor=west]{P};
    \node[above,yshift=0.2cm] at (0,3) {$\textup{C}_{0}$} ;
   \node[below,yshift=-0.2cm] at (0,3) {0} ;
   \node[below,yshift=-0.2cm] at (1,3) {1} ;
    \node[below,yshift=-0.2cm] at (2,3) {2} ;
    \node[below,yshift=-0.3cm] at (4,3) {s} ;
    \node[below,yshift=-0.2cm] at (6,3) {n-2} ;
    \node[below,yshift=-0.2cm] at (7,3) {n-1} ;
    \node[below,yshift=-0.3cm] at (8,3) {n} ;

    \node[] at (0,3) {$|$} ;
    \node[] at (1,3) {$|$} ;
    \node[] at (2,3) {$|$} ;
    \node[] at (4,3) {$|$} ;
    \node[] at (6,3) {$|$} ;
    \node[] at (7,3) {$|$} ;
    \node[] at (8,3) {$|$} ;


    \draw[thick] (0,0)node[anchor=east]{A} --(2.2,0);
   \draw[thick] (2.2,0) --(2.5,0.2)--(3,-0.2)--(3.2,0)--(4.2,0)--(4.5,0.2)--(5,-0.2)--(5.2,0)--(8,0)node[anchor=west]{CP};

    \node[above,yshift=0.2cm] at (1,0) {a} ;
    \node[above,yshift=0.2cm] at (2,0) {a} ;
    \node[above,yshift=0.2cm] at (4,0) {a} ;
    \node[above,yshift=0.2cm] at (6,0) {a} ;
    \node[above,yshift=0.2cm] at (7,0) {a} ;
    \node[above,yshift=0.2cm] at (8,0) {a} ;

    \node[below,yshift=-0.2cm] at (0,0) {0} ;
    \node[below,yshift=-0.2cm] at (1,0) {1} ;
    \node[below,yshift=-0.2cm] at (2,0) {2} ;
    \node[below,yshift=-0.3cm] at (4,0) {s} ;
    \node[below,yshift=-0.2cm] at (6,0) {n-2} ;
    \node[below,yshift=-0.2cm] at (7,0) {n-1} ;
    \node[below,yshift=-0.3cm] at (8,0) {n} ;


    \node[] at (0,0) {$|$} ;
    \node[] at (1,0) {$|$} ;
    \node[] at (2,0) {$|$} ;
    \node[] at (4,0) {$|$} ;
    \node[] at (6,0) {$|$} ;
    \node[] at (7,0) {$|$} ;
    \node[] at (8,0) {$|$} ;

  \end{tikzpicture}
  \end{center}


  \end{document}

在此处输入图片描述

相关内容