You should not always use the node feature. Sometimes you need the coordinates of the node, if you don't it can often pay to do it "manually" (less code).
I have here compiled 2 methods, one where yours is corrected, and the other without the use of nodes. I prefer the one without nodes as it is more drawing clean, but everyone can prefer whatever style they want!
Without node
\begin{tikzpicture}[scale=1]
\foreach \y in {0.0,0.1,...,0.9} {
\foreach \x in {0.0,0.1,...,0.9} {
\pgfmathparse{0.9*rnd+0.3}
\definecolor{MyColor}{rgb}{\pgfmathresult,\pgfmathresult,\pgfmathresult}
\path[fill=MyColor] (\x,\y) rectangle ++(0.1,0.1);
}
}
\draw[step=.1,help lines] (0,0) grid (1,1);
\draw[->] (0,1) -- (1.2,1);
\draw[->] (0,1) -- (0,-0.2);
\end{tikzpicture}
As you can see you just draw a rectangle and fill it with the color of your choice.
Fixed code
What you need to ensure is correct placement, and correct size. A node usually has some space associated with the filling of the text. This space is to ensure not too tight a drawing compared to the text, compare the following two tikz drawings:
\tikz \node[draw,inner sep=0pt,outer sep=0pt] {H};
\tikz \node[draw] {H};
Therefore i have added that you do not want any outer sep, but kept an inner sep which has the size of your node.
Next is your ability to place the node with respect to its size. Here anchor is your friend, it basically tells if the node should be placed at the coordinate anchoring the node at the coordinate within the node. Try for instance and change anchor=center to anchor=east. With anchor=center it takes the center coordinate in the node and place at the coordinate you specify. With anchor=east it takes the east point of the node and places at the coordinate.
It is strictly not needed in the below example, but gives a good idea what it does (and it is VERY useful)
\begin{tikzpicture}[scale=1]
\foreach \y in {0.1,0.2,...,.9} {
\foreach \x in {0.1,0.2,...,.9} {
\pgfmathparse{0.9*rnd+0.3}
\definecolor{MyColor}{rgb}{\pgfmathresult,\pgfmathresult,\pgfmathresult}
\node[fill=MyColor,inner sep=0.1cm,outer sep=0pt,anchor=center] at (\x,\y) {};
}
}
\draw[step=.1,help lines] (0,0) grid (1,1);
\draw[->] (0,1) -- (1.2,1);
\draw[->] (0,1) -- (0,-0.2);
\end{tikzpicture}
Hope this brings you in the correct direction.
Colors in tikz
Also when defining new colors you can skip a define color step:
\pgfmathparse{70*rnd+30}
\edef\tmp{\pgfmathresult}
\node[fill=white!\tmp!black] ...
In this case you skip the \definecolor, and need not worry about that. In this case the number should be between 0 and 100.
Further more you need the \edef step to keep that result. There is a lot of math going on in tikz so you need to save the math variable temporarily (which is why \edef is needed.)
minimum size=1mm,inner sep=0,outer sep=0instead ofminimum size=0.1. Also it is useful to write upgrid (1cm,1cm)so you can keep track of the units :) – percusse Dec 06 '11 at 10:01transform shapeto thetikzpictureenvironment. That will enlarge everything together. Regarding thecmthing, it is just a matter of taste probably. Nevermind that :) – percusse Dec 06 '11 at 10:12