[Tex/LaTex] control the ‘density’ of a pattern in TikZ


…i.e. I want to control the spacing between lines in a hatch pattern. Is that possible at all with the predefined patterns from the pattern library, like north east lines? Or should I just create my own pattern? I tried the step modifier, but it has no effect as in the minimal non-working example below. 😉

    \draw [step=0.5cm, pattern=north east lines] (0,0) rectangle (1.4,1.4);

EDIT: I changed the code a bit, because I would like to control the spacing in any type of pattern and originally in the example was grid.

Best Answer

As Gonzalo says the patterns are not customizable. So, here is one way you can customize the code for the grid pattern to accept a variable that allows you to control the density by adjusting the GridSize=1pt. The default is GridSize=3pt




   \draw [GridSize=1pt, pattern=MyGrid] (0,0) rectangle (1.4,1.4);