如何画一幅画

如何画一幅画

我想画下面的图,但目前不知道该怎么做:在此处输入图片描述

有什么想法或建议吗?

答案1

在此处输入图片描述

使用几个\foreach循环就可以很快绘制出来:

\documentclass[tikz, border=20]{standalone}

\begin{document}
    \pgfmathsetmacro{\r}{0.05}
    \begin{tikzpicture}
        \tikzset{axis/.style={->, >=latex, thick}}
        \tikzset{other lines/.style={thick}}
        \draw[axis] (-1, 0) -- (10, 0);
        \draw[axis] (0, -1) -- (0, 6);
        \foreach \x in {0, 0.5, 1, 6.5} {
            \draw[fill=black] (\x, 0) circle[radius=\r];
        }
        \foreach \x in {0, 0.5, ..., 7.5} {
            \draw[fill=black] (\x, 0.5) circle[radius=\r];
            \draw[fill=black] (\x, 1) circle[radius=\r];
        }
        \foreach \x in {5, 5.5, ..., 7.5} {
            \draw[fill=black] (\x, 1.5) circle[radius=\r];
        }
        \foreach \y in {2, 2.5, ..., 3.5} {
            \draw[fill=black] (6.5, \y) circle[radius=\r];
        }
        \draw[fill=black] (0, 4) circle[radius=\r];
        
        \draw[other lines] (0, 0) -- (10, 5) node[pos=0.7, above] {\(D\)};
        \draw[other lines] (9, 0) -- (9, 4.5);
        \draw[other lines] (0, 4.5) -- (9, 4.5);
        \node[below left] at (0, 0) {\((0, 0)\)};
        \node[below] at (6.5, 0) {\((k, 0)\)};
        \node[below] at (9, 0) {\((p/2, 0)\)};
        \node[left] at (0, 4) {\((0, f)\)};
        \node[left] at (0, 4.5) {\((0, q/2)\)};
        \node[below right] at (9, 4.5) {\((p/2, q/2)\)};
        \node[right] at (6.5, 3) {\((k, kq/p)\)};
        \node at (8, 2) {\(T_1\)};
        \node at (2, 4) {\(T_2\)};
    \end{tikzpicture}
\end{document}

编辑:添加了缺失的坐标标签,谢谢@金正恩指出这一点。

相关内容