# Tikz scale vs pgf scale

The following code shows that the tikz "scale" is different from pgf?

Changing the scale values for x and y in the tikzset command will scale the tikz rectangle but not the pgf star. Any ideas how to reconcile this? I need to be able to to scale my tikz pictures easily but have pgf use the same scale and origin.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes.callouts,shapes.geometric}
\begin{document}
\tikzset{x=0.1in,y=0.1in}
\begin{tikzpicture}
\draw[top color= black!50] (-2,-2) rectangle (5,4);

\begin{scope}
\pgfset{minimum width=1.5cm,minimum height=1.5cm}
\pgftransformshift{\pgfpoint{2cm}{2cm}}
\pgfnode{star}{center}{}{}{\pgfusepath{clip}}
\pgftransformreset
% Back to drawing
\fill[yellow] (2cm,2cm) circle (0.65cm);
\end{scope}
\end{tikzpicture}
\end{document}

-
You can try \makeatletter \pgfsys@transformxyscale{2}{2} – Alain Matthes Apr 27 '12 at 20:39
that seems to work! – Uiy Apr 27 '12 at 20:41
unfortunately that does not scale the node text by itself... – Uiy Apr 27 '12 at 20:43
Your star is a node. Generally, nodes don't scale with TikZ - you have to explicitly tell them to do so. You're mixing TikZ and PGF commands which might mess things up a little, though, so there might be more to it than that. If you used pure TikZ I'd say you should put the transform shape key on the node command. – Loop Space Apr 27 '12 at 20:43
@AndrewStacey Ok, that works. Another problem now is that my tikzpictures do not all have the same scale. The first one is larger than the others on these same page. I had no scaling issues using tikzset. – Uiy Apr 27 '12 at 20:51

The main difficulty is that the scale and transform shape keys belong to /tikz/ family and does not penetrate down to PGF level. Instead they are mapped with rather tedious mechanisms. Hence, we need to somewhat fake it with low level transformation commands. If for some reasons we still need to use [x=0.1in,y=0.1in] we have to add the corresponding \pgfsetxvec and \pgfsetyvec commands appropriately to mimic the TikZ effect.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric}

\begin{document}
\begin{tikzpicture}[scale=.75]
\pgfgettransform{\somemacro}
\draw[top color= black!50] (-2cm,-2cm) rectangle (5cm,4cm);
\draw[style=help lines] (-2cm,-2cm) grid[step=1cm] (5cm,4cm);
\node (o) at (0,0) {0};

\begin{scope}
\pgfset{minimum width=1.5cm,minimum height=1.5cm}
\pgftransformshift{\pgfpoint{3cm}{0cm}}
\pgfnode{star}{center}{}{}{\pgfusepath{clip}}
\pgfsettransform{\somemacro}
\fill[yellow] (3cm,0cm) circle (0.65cm);
\end{scope}

\node[draw,circle,transform shape] (dum) at (2,2) {(2,2)};

\begin{scope}
\pgfset{minimum width=2cm,minimum height=2cm}
\pgftransformshift{\pgfpoint{0cm}{2.5cm}}
\pgfnode{star}{center}{}{}{\pgfusepath{clip}}
\pgfsettransform{\somemacro}
\fill[red] (0cm,2.5cm) circle (0.8cm);
\end{scope}

\end{tikzpicture}
\end{document}


-
I'm still having issues with the scaling. Add/modify your code to use \begin{tikzpicture}[scale=.35, transform shape] \tikzset{x=1in,y=1in} \makeatletter\pgfsys@transformxyscale{0.35}{0.35}... All I'm trying to do now is get the tikz scaling that I'm using to match with the pgf scaling. – Uiy Apr 28 '12 at 23:22
If you do not use the tikzset line then the tikz scale in tikzpicture is not overridden by the pgf scale. It seems they are interacting insome weird or unexpected way. Also I guess I do not understand what the tikzset is actually doing... Seems like it is actually just shifting the origin than anything. – Uiy Apr 28 '12 at 23:27
ok, what it seems like is some scale factor difference. I took out the scale factor from the tikzpicture and used only the makeat one. The scale factor then is applied globally and each new picture environment is scaled repeatedly(so each new picture is scaled down by another extra factor). Should be easy to fix by saving the transform and restoring. BUT all the pgf code in the setclip lua function seems to be using a different scaling factor as it maps to the data exactly if shrunk. This could have to do with the dimension/units issue. – Uiy Apr 28 '12 at 23:32
The problem is, I can't seem to scale just one or the other to get them to match. I think it is the pgfsys transform that I'm using as it is messing up tikz. (I might need to use it outside the tikz frame or calculate my own scaling factors instead of using it in setclip) – Uiy Apr 28 '12 at 23:35
Multiplying the pgf coordinates(the x and y in setclip) by 1/2.54 fixes the problem. I guess the pgf dimensions are in cm by default and I'm using inches in my tikz code. (since my engineering drawings are in inches) This gets everything aligned and properly clipped like it is suppose to be. I'll have to play around with it some more to see if anything else is broken but it looks right so far. – Uiy Apr 28 '12 at 23:41