答案1
作为@Andy Wang 答案(+1)的补充,展示如何通过定义点的样式来缩短代码:
\documentclass[border=3.141592]{standalone}
\usepackage{pgfplots} % it load tikz too
\usetikzlibrary{arrows.meta}
\begin{document}
\begin{tikzpicture}[
> = {Straight Barb[scale=0.8]},
dot/.style = {circle, draw, fill=#1, inner sep=2pt}
]
\draw[help lines] (-5, -5) grid (5, 5);
% draw coordinate axes
\draw[<->, thick] (-5.5,0) -- (5.5,0) node[right] {$x$};
\draw[<->, thick] (0,-5.5) -- (0,5.5) node[above] {$y$};
% dots
\node[dot=black, label=A] at (-3,3) {};
\node[dot=blue, label=B] at (-1,1) {};
\node[dot=red, label=C] at (2, 3) {};
\node[dot=yellow, label=D] at (4, 1) {};
\node[dot=green, label=E] at (2,-3) {};
\end{tikzpicture}
\end{document}
答案2
\documentclass{article}
\usepackage{pgfplots}
\usepackage{tikz}
\usetikzlibrary{arrows.meta}
\begin{document}
\begin{tikzpicture}
\draw[help lines] (-5, -5) grid (5, 5);
% draw coordinate axes
\draw[<->, thick](-5.5,0)--(5.5,0)node[right]{$x$};
\draw[<->, thick](0,-5.5)--(0,5.5)node[above]{$y$};
\node[circle, draw, fill=black, inner sep=2pt, label=A] at (-3, 3) {};
\node[circle, draw, fill=blue, inner sep=2pt, label=B] at (-1, 1) {};
\node[circle, draw, fill=red, inner sep=2pt, label=C] at (2, 3) {};
\node[circle, draw, fill=yellow, inner sep=2pt, label=D] at (4, 1) {};
\node[circle, draw, fill=green, inner sep=2pt, label=E] at (2, -3) {};
\end{tikzpicture}
\end{document}