TikZ automatically adds separation between the text and the node border. When setting a minimum size for a node, it's usually a good idea to set inner sep=0pt
:
\tikzstyle{m}=[circle, thin, draw=red, fill=red, minimum size=4mm,inner sep=0pt]
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}
![Result](https://i.stack.imgur.com/hmIFE.png)
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:
- 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.
- 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.
Your requested circle:
\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.
![Circles](https://i.stack.imgur.com/osDvM.png)
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}
![Shape](https://i.stack.imgur.com/4YmsW.png)
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.
Best Answer
Add
font=\bfseries
: