# how to draw the same type of circle at different positions using tikz?

\draw [fill=black] (4,6) circle (0.3cm);
\draw [fill=black] (3,4.5) circle (0.3cm);


How can I define a circle called user with radius 0.3cm and fill black and just specify the position every time i draw it?

-
Would you mind substituting the word shape for the word circle in your question? That would make the question a bit more general, so others may look at it when they need an answer to a similar question. (As a matter of fact it turns out you are actually interested in knowing how to draw arbitrary shapes with a given style.) – Marc van Dongen Feb 20 '13 at 9:09

Use a circular shaped node, without contents, and define the appropriate style for that node:

\tikzset{user/.style={circle, inner sep=0pt, minimum size=0.6cm, fill=black, draw=none}}
\begin{tikzpicture}
\node[user] at (4,6) {};
\node[user] at (3,4.5) {};
\end{tikzpicture}


An alternative syntax which will produce the same result:

\begin{tikzpicture}
\draw (4,6)   node[user]{}
(3,4.5) node[user]{};
\end{tikzpicture}


# Update

As Marc van Dongen suggested in a comment, a little explanation could be useful.

The solution based in node shapes was possible because you requested a filled circle, and there is a node shape called circle. This approach will work for any node shape, but if you need to fill-draw an arbitrary shape and there is not any node with that shape, you have two solutions:

1. Define your own node shape. This would be probably the right thing to do, but defining new node shapes is far from trivial since you have to use pgf's drawing primitives which are not as friendly as tikz syntax.
2. Define a standard latex command which does the drawing for you. In this case the problem is how to specify the coordinates so that you can place that shape at any arbitrary point. I think the easiest solution is to pass the "origin" as parameter and use relative coordinates (in the form of +(x,y) in the path construction.

A couple of examples for the second approach.

\newcommand{\mycircle}[2][fill=black]{
\draw[#1] (#2) circle(0.3cm);
}

\begin{tikzpicture}
\mycircle{4, 6}
\mycircle{3, 4.5}
\mycircle[fill=red, draw=none]{3.5,5}
\end{tikzpicture}


Note that I use an optional parameter #1 to be able to pass different options to the path. The default value for this parameter is fill=black but in this example I also use it to get a red circle. The center of the circle is passed as the second parameter.

2. A more complex (arbitrary) shape

\newcommand{\myshape}[2][fill=black]{
\draw[#1] (#2)
+(0.1,0.1) -- +(0.5, 0.6) --  +(0.1,-0.1) -- + (-0.2,0.2) -- cycle;
}

\begin{tikzpicture}
\myshape{4, 6}
\myshape{3, 4.5}
\end{tikzpicture}


In this case the points of the arbitrary shape are specified relative to its first point (which is argument #2 of the macro) using the + syntax in front of each coordinate.

-
This is probably the only solution but it would be nice if you could explain this works for any kind of node shape. Not for arbitrary shapes. (Of course it would also work with a to path but that would require providing two coordinates...) If you do this, the OP can substitute node shape for the word circle which makes the question a bit more general. – Marc van Dongen Feb 20 '13 at 8:18
I also wanted to draw rectangels, where I can i find details on a rectangles style? for e.g. size for circle – zcqwevb Feb 20 '13 at 8:26
how to do the same for a rectangle? – zcqwevb Feb 20 '13 at 8:31
@user494461 Rectangle is a standard tikz shape, so you can use the same approach than my first answer for the circle. To specify the rectangle size you have to use minimum width and minimum height. You may also consider the second way in the updated answer (but I would prefer the first one, because nodes have the ability to be named, having anchors, etc.) – JLDiaz Feb 20 '13 at 8:43
It's not clear whether @user494461 requires all the features of node shapes. In the simple examples above, the insert path key seems to be sufficient, for example, user/.style={insert path={circle [radius=0.3cm]}}. Then one can use \draw (3,2) [user];. Node shapes do useful things but are not always necessary. – Mark Wibrow Feb 20 '13 at 9:34