3

I have to draw the fallowing figure in LaTex but I don not know the code. enter image description here

2
8

A simple approach can be done by Tikz. The result of the following is

enter image description here

The code for the preceding output is

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

\usepackage{tikz}
\usetikzlibrary{positioning}

\begin{document}

\begin{tikzpicture}
    [%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        dot/.style={circle,draw=black, fill,inner sep=1pt},
    ]%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\foreach \x in {0,...,5}{
    \node[dot] at (\x,5){ };
    \node[dot] at (\x,4){ };
}

\foreach \x in {.2,1.2}
    \draw[thick] (\x,4) -- (\x+.6,4);
\foreach \x in {3.2,4.2}
    \draw[thick] (\x,2) -- (\x+.6,2);
\foreach \y in {1.8,.8}
    \draw[thick] (5,\y) -- (5,\y-.6);
\draw[thick] (2,3.8) -- (2,3.8-.6);
\draw[thick] (3,2.8) -- (3,2.8-.6);
\draw[thick] (2.2,3) -- (2.2+.6,3);
\foreach \x in {2,...,5}
    \node[dot] at (\x,3){};
\foreach \x in {3,...,5}
    \node[dot] at (\x,2){};

\foreach \x in {1,...,4}
    \draw (\x,.1) -- node[below,yshift=-1mm] {\x} (\x,-.1);
\node[below,yshift=-1mm] at (5,0) {5};
\node[below,xshift=-2mm,yshift=-1mm] at (0,0) {0};

\foreach \y in {1,...,3}
    \draw (.1,\y) -- node[below,xshift=-2mm] {\y} (-.1,\y);
\node[below,xshift=-2mm] at (0,4) {4};
\node[below,xshift=-2mm] at (0,5) {5};  
\node[dot] at (5,1){};  
\node[dot] at (5,0){};      
\draw[->,thick,-latex] (0,-1) -- (0,6);
\draw[->,thick,-latex] (-1,0) -- (6,0);
\end{tikzpicture}

\end{document}
2
  • Thank you so much. But there is a problem, i can not set the figure name below the figure. Nov 13 '16 at 20:34
  • 1
    @ShahnawazAhmad Put it into a figure environment and use \caption{}?
    – cfr
    Nov 14 '16 at 0:18

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.