需要帮助在 Latex 上绘制图表

需要帮助在 Latex 上绘制图表

我正在尝试绘制一个类似这样的图表。有人可以教我怎么做吗?

答案1

Z 提案

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

或者你可能想了解元帖子...

\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}

它包含在内,luamplib因此您需要使用 进行编译lualatex。输出如下所示:

enter image description here

相关内容