0

I am trying to make the following diagram with tikz but I have problems with the spikes. Any help would be appreciated. Thanks in advance!

enter image description here

  • 2
    This is by far not your first question, what have you tried so far? Can you show us an MWE with your code? – Huang_d Jun 29 '17 at 11:14
2

Used Biki Teron answer as starting point (instead missing 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}

enter image description here

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}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.