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?

  • 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 9: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 tex.stackexchange.com/q/9116 – yo' Sep 11 '14 at 9:39
  • 4
    "I tried" ... then please post the code by updating your question. – Svend Tveskæg Sep 11 '14 at 9:50
  • 4
    I don't want to discourage you, but starting LaTeX with such Graphics is ... say, ambitious – user31729 Sep 11 '14 at 10:07
  • 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
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

  • I'll come later on with more details. – Claudio Fiandrino Sep 11 '14 at 12:45
  • Thank you so much Claudio, You are the best. I am so happy and I will learn from your code. I wish u all the best, and thank u again. – Garry Sep 11 '14 at 12:53
  • @ClaudioFiandrino -- +1 for the nice work. – Jesse Sep 11 '14 at 14:48

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.