Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I wish to have a grid of points or dots along with the labels, and combine them into a single figure like the one below.

enter image description here

I tried the closest graph I can for the first grid in the top left, and here's the result of it,

\documentclass{article}   
\usepackage{tikz}
  \begin{tikzpicture}
    \foreach \x in {0,1,2,3,4,5,6}
    \foreach \y in {0,1,2,3,4,5,6}
    {
    \draw (\x,\y) circle (0.3cm);
    }
    \fill (3,4) node {\textbf{A}};
    \fill (4,3) node {\textbf{B}};
    \fill (3,3) node {\textbf{X}};
    \fill (3,2) node {\textbf{C}};
    \fill (2,3) node {\textbf{D}};
  \end{tikzpicture}
\end{document}

enter image description here

I would be happy if you could help me with the codes of these grids for both two and one dimension.

Thank you in advance!

share|improve this question

2 Answers 2

up vote 3 down vote accepted

This is not as elegant as cmhughes' answer. You can also use shifts and scopes to position the figures.

Code

%\documentclass{article}   
\documentclass[border=5,convert]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning, calc}
\tikzset{circle node/.style = {circle,inner sep=1pt,draw, fill=white},
        X node/.style = {fill=white, inner sep=1pt},
        dot node/.style = {circle, draw, inner sep=5pt}
}

\begin{document}
  \begin{tikzpicture}[scale=0.5]
    \foreach \x in {0,...,6}
    \foreach \y in {0,...,6}
    {
    \fill (\x,\y) circle (2pt);
    }
    \foreach \a/\b/\c in {3/4/A,4/3/B,3/2/C,2/3/D}
    \fill (\a,\b) node (\c) [circle node] {\textbf{\c}};
    \node [X node] at (3,3) {\textbf{X}};

    \node at (11,3) {FIRST ORDER};

    \begin{scope}[shift={(15,3)}]
    \foreach \x in {0,...,8}
        \fill (\x,0) circle (2pt);  
    \node at (4,0) [X node] {\textbf{X}};
    \foreach \x in {3,5}
        \node [dot node] at (\x,0) {};
    \end{scope}

    \begin{scope}[shift={(0,-8)}]
        \foreach \x in {0,...,6}
        \foreach \y in {0,...,6}
        {
        \fill (\x,\y) circle (2pt);
        }
        \foreach \a/\b/\c in {2/4/E,4/4/F,4/2/G,2/2/H}
        \fill (\a,\b) node [circle node] {\textbf{\c}};
        \node [X node] at (3,3) {\textbf{X}};

        \node at (11,3) {SECOND ORDER};

        \begin{scope}[shift={(15,3)}]
            \foreach \x in {0,...,8}
            \fill (\x,0) circle (2pt);  
            \node at (4,0) [X node] {\textbf{X}};
            \foreach \x in {2,6}
            \node [dot node] at (\x,0) {};
        \end{scope}
    \end{scope}
  \end{tikzpicture}
\end{document}

Output

enter image description here

share|improve this answer
    
Thank you very much hpesoj626! You have a nice grids! Thank you for your effort, you gave me an idea on how to put a labels...! –  Al-Ahmadgaid Asaad Feb 2 '13 at 5:45

Here's something to get you started

screenshot

The idea is to set up nodes using the foreach command and name them as x-y. You can then circle the appropriate nodes.

The coordinate system starts at (0,0) and goes up to (8,8). You can adjust the scale as you see fit.

\documentclass{article}
\usepackage{tikz}

\tikzset{mystyle/.style={shape=circle,fill=black,scale=0.3}}
\tikzset{withtext/.style={fill=white}}

\begin{document}

\begin{figure}
    \begin{minipage}{.5\textwidth}
        \begin{tikzpicture}[scale=.5]
            % setup the nodes
            \foreach \x in {0,...,8}
            \foreach \y in {0,...,8}
            {
            \ifnum\x=4
                \ifnum\y=4
                    \node (\x-\y) at (\x,\y){X};
                \else
                    \node[mystyle] (\x-\y) at (\x,\y){};
                \fi
            \else
                \node[mystyle] (\x-\y) at (\x,\y){};
            \fi
            }
            % circle selected nodes with letters
            \foreach \mynode/\mytext in {4-3/A,3-4/B,5-4/C,4-5/D}
            {
                \draw[withtext] (\mynode) circle (0.4cm) node {\mytext};
            }
        \end{tikzpicture}
    \end{minipage}%
    \begin{minipage}{.5\textwidth}
        \begin{tikzpicture}[scale=.5]
            % setup the nodes
            \foreach \x in {0,...,8}
            {
            \ifnum\x=4
                \node (\x) at (\x,0){X};
            \else
                \node[mystyle] (\x) at (\x,0){};
            \fi
            }
            % circle selected nodes
            \foreach \mynode in {3,5}
            {
                \draw (\mynode) circle (0.3cm);
            }
        \end{tikzpicture}
    \end{minipage}%
\end{figure}

\end{document}
share|improve this answer
    
Thank you cmhughes, you got it. Thank you very much. I will try to add a labels on it. Thank you for your effort, I really appreciate it! –  Al-Ahmadgaid Asaad Feb 2 '13 at 5:38
1  
@Al-AhmadgaidAsaad I have added a version that puts A, B, C, D :) –  cmhughes Feb 2 '13 at 17:26
    
Hello cmhughes, I appreciate your edits on your answer. But I actually used both your answer and that one by hpesoj626. I want to look the way it is in my question. So I used the dots instead of alphabets, which is from your answer. Then, I used the positioning and labelling from hpesoj626. I just prefered his answer because it has a labels already and positions, and thus it was not difficult for me to add the last four grids. Anyways, both of you deserve more reputations, I just can't select two answers. :) Thank you again! –  Al-Ahmadgaid Asaad Feb 3 '13 at 2:16

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.