TikZ Grid Without Edges

If you make the coordinates not an exact multiple of the step size you can get this effect:

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
   \draw[step=0.5cm,color=gray] (.75,.75) grid (3.75,3.75);
\end{tikzpicture}
\end{document}

output of code


If you care for something a bit fancier, you could also try that one:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{fadings}
\begin{document}
\begin{tikzpicture}
   \draw[step=0.5cm,color=gray,path fading=south] (.99,.75) grid (3.5,1);
   \draw[step=0.5cm,color=gray,path fading=north] (.99,3.5) grid (3.5,3.75);
   \draw[step=0.5cm,color=gray,path fading=west] (.75,.99) grid (1,3.5);
   \draw[step=0.5cm,color=gray,path fading=east] (3.5,.99) grid (3.75,3.5);
   \draw[step=0.5cm,color=gray] (1,1) grid (3.5,3.5);
\end{tikzpicture}
\end{document}

output of code


I needed the same thing, but had things in the cells of the grid, which I also wanted to fade out. This solution is perhaps less elegant than others, but permits this sort of fading.

It just puts fading rectangles over the edges so they fade out to white.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{fadings}

\begin{document}
\begin{tikzpicture}
    \draw[step=0.5cm] (0.1,0.1) grid (3.9,3.9);
    % Some letters to demonstrate fading
    \node at (0.25,0.25) {F};
    \node at (0.75,0.75) {A};
    \node at (1.25,0.25) {D};
    \node at (1.75,0.75) {E};

    \begin{scope}[transparency group]
        % Left edge
        \fill[path fading=east, color=white] (0,0) rectangle (1,4);
        % Bottom edge
        \fill[path fading=north, color=white] (0,0) rectangle (4,1);
        % Right edge
        \fill[path fading=west, color=white] (3,0) rectangle (4,4);
        % Top edge
        \fill[path fading=south, color=white] (0,3) rectangle (4,4);
    \end{scope}
\end{tikzpicture}
\end{document}

enter image description here

Tags:

Tikz Pgf

Grids