5

patch simulation

I am trying to code the above picture.
This is my current code, but it does not look like the intended figure:

\begin{tikzpicture}
\draw[thick,->] (0,0) -- (8.5,0);
\draw[thick,->] (0,0) -- (0,4.5);
\draw[thick,-] (1,0) -- (1,1);
\draw[thick,-] (2,0) -- (2,1);
\draw[thick,-] (3,0) -- (3,1);
\draw[thick,-] (4,0) -- (4,1);
\draw[thick,-] (5,0) -- (5,1);
\draw[thick,-] (6,0) -- (6,1);
\draw[thick,-] (7,0) -- (7,1);
%\draw[thick,-] (4,0) -- (4,1);
\foreach \x in {0,1,2,3,4,5,6,7,8}
    \draw (\x cm,1pt) -- (\x cm,-1pt) node[anchor=north] {$\x$};
\foreach \y in {0,1,2,3,4}
    \draw (1pt,\y cm) -- (-1pt,\y cm) node[anchor=east] {$\y$};
\end{tikzpicture}

How can I change my code to obtain the desired output?

Schorsch
  • 585
Garry
  • 491
  • 2
    Welcome to TeX.SX. Questions about how to draw specific graphics that just post an image of the desired result are really not reasonable questions to ask on the site. Please post a minimal compilable document showing that you've tried to produce the image and then people will be happy to help you with any specific problems you may have. See minimal working example (MWE) for what needs to go into such a document. – egreg Sep 11 '14 at 09:36
  • 3
    Hello! Well, we could draw this for you, but we generally don't like to do that, it's a bit like "do this for me", and we are a support place, not a non-paid service place. Moreover, if you learn to do it by yourself (and not just copy the code someone makes for you here), you'll advance your skills and won't need to ask basic questions next time ;) Some guides for one of the drawing libraries, TikZ, can be found in http://tex.stackexchange.com/q/9116/ – yo' Sep 11 '14 at 09:39
  • 4
    "I tried" ... then please post the code by updating your question. – Svend Tveskæg Sep 11 '14 at 09:50
  • 4
    I don't want to discourage you, but starting LaTeX with such Graphics is ... say, ambitious –  Sep 11 '14 at 10:07
  • A tip: If you indent lines by 4 spaces, they'll be marked as a code sample. You can also highlight the code and click the button marked with a {} symbol. – eiterorm Sep 11 '14 at 11:29
  • Hi eiterorm, thank you for ur tip but I did not knw what u mean? – Garry Sep 11 '14 at 11:41
  • 3
    Please use proper English language and not "u plz ur". I removed some now obsolete comments, which have been read already to keep the discussion focused. Just to better see the remaining technical content (advice such as "be patient" does not need to stay once you read it). Just if I would see such badly readable language again, I would immediately remove. Feel free to come to the TeX chat with such speak. I just fear that our friends in chat might be too grown up for this. – Stefan Kottwitz Sep 11 '14 at 14:33

1 Answers1

12

A start of solution using pic operation:

\documentclass[tikz,border=10pt]{standalone}

\tikzset{sequence label/.store in=\seqlab,
  sequence label={},
  sequence/.pic={
   \fill (0,0) circle[radius=2pt] node[below]{\seqlab};
   \draw (-1,0)--++(0,1);
   \draw (-0.6,0)--++(0,1);
   \draw (1,0)--++(0,1);
   \draw (0.6,0)--++(0,1);
   \begin{scope}[font=\tiny,blue!50!cyan!80!black]
   \node at (-0.8,0.8){BC};
   \node at (0.8,0.8){BC};
   \node at (0,0.8){Patch};
   \end{scope}
   \draw[stealth-stealth](-0.6,0.6)--(0.6,0.6)
     node[below,midway,font=\tiny]{$\Delta X$};
   \coordinate(-West) at (-1,0.6);
   \coordinate(-East) at (1,0.6);
 }
}

\begin{document}
\begin{tikzpicture}
\draw (0,-0.5)--++(0,3) (-0.5,0)--++(13,0);
\draw[sequence label=$X_i$] pic (A) at (1.5,0) {sequence};

\draw[sequence label=$X_{i+1}$] pic (B) at (6,0) {sequence};

\draw[sequence label=$X_{i+2}$] pic (C) at (10.5,0) {sequence};

% ARROWS in BETWEEN
\draw[stealth-stealth,blue!50!cyan!80!black](A-East)--(B-West)
     node[above,midway,font=\tiny] {Gap}
     node[below,midway,font=\tiny,text=black]{$\Delta X$};

\draw[stealth-stealth,blue!50!cyan!80!black](B-East)--(C-West)
     node[above,midway,font=\tiny] {Gap}
     node[below,midway,font=\tiny,text=black]{$\Delta X$};
\end{tikzpicture}
\end{document}

The result: enter image description here