# Size relative to line thickness/invariant under scaling

How to I realize a dot (here just drawn as a circle) which stays the same size no matter how I scale the image.

Here is the example.

\begin{tikzpicture}[scale=1]
\draw[thick] (0,0)--(1,0);
\fill (0,0) circle (1pt);
\end{tikzpicture}

\begin{tikzpicture}[scale=3]
\draw[thick] (0,0)--(1,0);
\fill (0,0) circle (1pt);
\end{tikzpicture}


Probably I should use node instead of drawing another circle.

I used to use a node with ${\bullet}$ but this is not precisely centered and I cannot control the size.

edit The following works partially, but not for a not centered point:

\begin{tikzpicture}[scale=1]
\draw[thick] (0,0)--(1,0);
\fill[shift only] (0,0) circle (1pt);
\fill[shift only] (1,0) circle (1pt);
\end{tikzpicture}
\begin{tikzpicture}[scale=3]
\draw[thick] (0,0)--(1,0);
\fill[shift only] (0,0) circle (1pt);
\fill[shift only] (1,0) circle (1pt);
\end{tikzpicture}
\begin{tikzpicture}[scale=3]
\draw[thick] (0,0)--(1,0);
\fill[shift only] (0,0) circle (1pt);
\fill(1,0) {[shift only] circle (1pt)};
\end{tikzpicture}


Alternatively, how to draw a dot at a specific point having a fixed size w.r.t. to the line thickness, e.g. 1.5x as thick as a thick line.

• which one is the wrong one and with negative scaling? Oct 27 '14 at 22:35
• the points should stay at the end points of the line is scaled... Oct 27 '14 at 22:36

You can reset the nontranslational scaling via shift only key. This will keep the translational part of the transformation but will set the matrix to identity. If you also want to cancel the current transformation you can use reset cm key.

\begin{tikzpicture}[scale=3]
\draw[thick] (0,0)--(1,0);
\fill[shift only] (0,0) circle (1pt);
\end{tikzpicture}


For the edit

\begin{tikzpicture}[xscale=-1,yscale=-0.3]
\draw[thick] (0.5,0.5)--(-0.2,-1);
\fill (0.5,0.5) circle[shift only,radius=1pt];
\fill (-0.2,-1) circle[shift only,radius=1pt];
\end{tikzpicture}


• Very nice. Didn't know about this feature. Many thanks Oct 27 '14 at 21:28
• Wow... You are great. This feature is nice indeed. Oct 27 '14 at 21:30
• Still makes a problem because I also use xscale=-1 to reflect images. Oct 27 '14 at 22:03
• @Marcel Change my example and it should be OK. Maybe your example is different in your actual case. I also feel like you are overusing scale keys. Oct 27 '14 at 22:10
• The problem is the point is not always in (0,0) ... Oct 27 '14 at 22:12

The solution is easy, move the scale code inside the path. Don't apply it to the whole tikz code:

Before:

After:

\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows,positioning,shapes.geometric}
\begin{document}
\begin{tikzpicture}[scale=1]
\draw[thick] (0,0)--(1,0);
\fill (0,0) circle (1pt);
\end{tikzpicture}

\begin{tikzpicture}
\draw[thick, scale=3] (0,0)--(1,0);
\fill (0,0) circle (1pt);
\end{tikzpicture}
\end{document}

• This way around it would not help, but I can put the scale to the dot Oct 27 '14 at 21:15
• @Marcel Yes, you may scale up the whole tikz box and then scale down the dot. Oct 27 '14 at 21:17
• Yes the point is I want the size relative to the line width and the overall scale is arbitrary, because I have a lot pictures which are more complicated like this. Oct 27 '14 at 21:21

Another way could be to do some math when setting the dot's size:

\documentclass[tikz, border=5mm]{standalone}

\newcommand{\myscale}{1}

\begin{document}
\begin{tikzpicture}[scale=\myscale]
\draw[thick] (0,0)--(1,0);
\fill (0,0) circle (1pt/\myscale);
\end{tikzpicture}

\renewcommand{\myscale}{3}

\begin{tikzpicture}[scale=\myscale]
\draw[thick] (0,0)--(1,0);
\fill (0,0) circle (1pt/\myscale);
\end{tikzpicture}
\end{document}


This way you can control, which elements should be (relative) scaled and which not.

For easier reuse of already written code you can use it this way:

\documentclass[tikz, border=5mm]{standalone}

\newcommand{\myimage}[2][1]{
\begin{scope}[shift={#2}, scale=#1]
\draw [thick] (0,0) -- (1,0);
\fill (0,0) circle (1pt/#1);
\end{scope}
}

\begin{document}
\begin{tikzpicture}
\myimage{(0,1)};
\myimage[3]{(0,0)};
\end{tikzpicture}
\end{document}

• The point is I have a lot of images with dots on lines. I want to rescale them but the dots should stay the same relative to the line width. I have no idea of the scale because it is nested and too complicated... Oct 27 '14 at 21:29

I came up with a bit messy solution. Still not considering it elegant. It is a combination of the other solutions so far...

\documentclass[border=10]{standalone}
\usepackage{tikz}
\newcommand{\mydot}[1]{
\begin{scope}[shift={#1}]
\fill[shift only] (0,0) circle (1.3pt);
\end{scope}}
\begin{document}
\begin{tikzpicture}[scale=1]
\draw[thick] (0,0)--(1,0);
\mydot{(0,0)};
\mydot{(1,0)};
\end{tikzpicture}
\begin{tikzpicture}[scale=3]
\draw[thick] (0,0)--(1,0);
\mydot{(0,0)};
\mydot{(1,0)};
\end{tikzpicture}
\end{document}