3

I am very new to LaTex, I coded a grid but need to add plots or dots to them, but not sure how to add them. Here is the simple code I have:

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw[thick, black] (0,0) grid (4,4);
\end{tikzpicture}
\end{document}

It's a simple grid, but not sure how to add plots to them as shown below.
enter image description here

3 Answers 3

3

Here you are!

enter image description here

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw[thick] (0,0) grid (4,4);
\fill[red] (2,2) circle(.15);
\foreach \p in {(2,1),(2,3),(1,2),(3,2)}
\fill \p circle(.15);
\end{tikzpicture}
\end{document}
3

Another option

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[every plot/.style={mark=*, mark size=1.5mm, only marks}]
\draw[thick] (0,0) grid (4,4);
\draw plot coordinates{(1,2) (2,1) (2,3) (3,2)};
\draw[red] plot coordinates{(2,2)};
\end{tikzpicture}
\end{document}

enter image description here

2

Just for fun, another option :

screenshot

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw[thick] (0,0) grid (4,4);
\node[draw, circle,fill=red]at (2,2){};
\foreach \p in {(2,1),(2,3),(1,2),(3,2)}
\node[draw, circle,fill]at \p {};
\end{tikzpicture}
\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .