0

I am trying to draw a graph look like this. Anyone can teach me how to do it?

5

A TikZ proposal

enter image description here

\documentclass[tikz,margin=0.5cm]{standalone}

\begin{document}
\begin{tikzpicture}

\tikzstyle{smallnodes}=[circle,draw,inner sep=1pt,fill=white]

\pgfmathsetmacro{\a}{1.5}
\pgfmathsetmacro{\axisX}{2.5}
\pgfmathsetmacro{\axisY}{2.7}
\pgfmathsetmacro{\dashedX}{2.5}
\pgfmathsetmacro{\dashedY}{2.5}
\pgfmathsetmacro{\Ooffset}{0.5}

\draw [->] (-\axisX,0) node [smallnodes,right,xshift=0.1cm] {4} --(\axisX,0) node [right] {$s$} node [smallnodes,left,xshift=-0.1cm] {3};
\draw [->] (0,-\axisY) node [smallnodes,above,yshift=0.1cm] {2} --(0,\axisY) node [above] {$t$} node [smallnodes,below,yshift=-0.1cm] {1};

\draw [dashed] (\a,-\dashedY)--(\a,\dashedY) (-\a,-\dashedY)--(-\a,\dashedY);
\draw [dashed] (-\dashedX,\a)--(\dashedX,\a)  (-\dashedX,-\a)--(\dashedX,-\a) ;

\node [below left] at (0,\a) {$a$};
\node [below left] at (\a,0) {$a$};
\node [below left] at (0,-\a) {$-a$};
\node [below left] at (-\a,0) {$-a$};

\node at (\a+\Ooffset,\a+\Ooffset) {0};
\node at (\a+\Ooffset,-\a-\Ooffset) {0};
\node at (-\a-\Ooffset,\a+\Ooffset) {0};
\node at (-\a-\Ooffset,-\a-\Ooffset) {0};

\node [circle,draw,fill=white] at (0,0) {5};

\end{tikzpicture}
\end{document}
2

Or you might like to learn Metapost...

\documentclass[border=5mm]{standalone}
\usepackage{luatex85}
\usepackage{luamplib}
\begin{document}
\mplibtextextlabel{enable}
\begin{mplibcode}
beginfig(1);

    path xx, yy;
    xx = (left--right) scaled 123;
    yy = xx rotated 90;

    drawoptions(withcolor 2/3 blue);

    drawarrow xx; label.rt("$s$", point 1 of xx);
    drawarrow yy; label.top("$t$", point 1 of yy);

    draw xx shifted 80 up   dashed evenly;
    draw xx shifted 80 down dashed evenly;
    draw yy shifted 80 left dashed evenly;
    draw yy shifted 80 right dashed evenly;

    for x=-1 upto 1:
        for y=-1 upto 1:
            unfill fullcircle scaled 16 shifted 100(x,y);
              draw fullcircle scaled 16 shifted 100(x,y);
        endfor
    endfor

    label("$1$", 100 up);
    label("$2$", 100 down);
    label("$3$", 100 right);
    label("$4$", 100 left);
    label("$5$", origin);

    dotlabel.ulft("$a$", 80 right);
    dotlabel.ulft("$a$", 80 up);
    dotlabel.llft("$-a$", 80 down);
    dotlabel.urt ("$-a$", 80 left);

endfig;
\end{mplibcode}
\end{document}

This is wrapped up in luamplib so you need to compile it with lualatex. The output looks like this:

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.