5

Can you explain why TikZ places the node center incorrectly in this MWE? I expect the red node to overlap the black one entirely, but it does not. If I remove the scaling, the problem goes away.

\documentclass[tikz, border=10]{standalone} \usepackage{tikz} \usetikzlibrary{calc} \begin{document} \begin{tikzpicture}[xscale=-100,yscale=-100] \tikzstyle{every node}=[inner sep=0pt,outer sep=1pt,minimum size=2mm,draw=black,fill=black,circle] \node (A) at (2,2) {}; \node at (A.center) [red] {}; \end{tikzpicture} \end{document} 

enter image description here

7
  • Use \begin{tikzpicture}[xscale=-100,yscale=-100,transform shape] for more surprises. Commented Apr 10, 2015 at 0:29
  • I am not so good with tikz but aren't you placing the bottom left corner of the red node at the center of the black node? Commented Apr 10, 2015 at 1:06
  • @MatoBehr No, the coordinate you give it is the center of the node. Commented Apr 10, 2015 at 2:03
  • 1
    This seems to be caused by a rounding error when TikZ is scaling and retrieving the coordinates for the center of the node. You can repeat this by writing \node (B) at (A.center) [red] {}; and then create a node C etc. Then examine the coordinates for the center of these nodes using: \foreach \myn in {A,B,C} {\pgfextractx\aex{\pgfpointanchor{\myn}{center}} \pgfextractx\aey{\pgfpointanchor{\myn}{center}} \typeout{==> \myn ==> [\the\aecm]\the\aex,\the\aey}} where \aex, \aey, and \aecm are lengths, and \aecm has length 1 cm. Commented Apr 10, 2015 at 4:06
  • The problem is just barely visible at scale=10, while scale=8 looks fine. Commented Apr 10, 2015 at 4:20

1 Answer 1

1

try this

\documentclass[tikz, border=10]{standalone} \usepackage{tikz} \usetikzlibrary{calc} \begin{document} \begin{tikzpicture}[xscale=-100,yscale=-100] \tikzstyle{every node}=[inner sep=0pt,outer sep=1pt,minimum size=2mm,draw=black,fill=black,circle] \coordinate (a) at (2,2); \node (A) at (a) {}; \node (B) at (a) [red] {}; \end{tikzpicture} \end{document} 

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.