Imagine I have two quite unrelated scopes:
- Scope 1: A geometric drawing with exact dimensions in millimeters and an overall scaling factor
- Scope 2: A circuittikz drawing using the normal dimensionless grid
Now I would like to place both scopes on top of each other, but vertically and horizontally aligned. I tried to use the local bounding box of the first scope, but as the second scope does not have a mid/center anchor point I don't know how to align the two scopes.
Please assume:
- The scaling factor of the first scope is arbitrary and should not be used
- I do know the coordinate of the center point of the second scope
Do you know how I could shift the inner coordinate system of the second scope, so the origin lies in the center? Or is it somehow possible to determine the center of the second scope automatically and use it for alignment?
MWE
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\begin{scope}[scale=2, local bounding box = scope1]
\draw[fill=blue, opacity = 0.5] (0,0) rectangle (1,1);
\end{scope}
\begin{scope}[scale=1.5, shift={(scope1.center)}]
\draw[fill=red, opacity = 0.5] (0,0) rectangle (1,1);
\end{scope}
\end{tikzpicture}
\end{document}
What I get
What I want
Thank you very much for your help!
More complex MWE
Imagine I would like to center the resistor inside the rectangle:
\documentclass{article}
\usepackage{tikz}
\usepackage{circuitikz}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
\begin{scope}[scale=1.5, local bounding box = scope1]
% These are real dimensions of a more complex geometry
\filldraw[thin, fill = gray!20!white] (0mm,0mm)
-- ++(0mm, 7mm)
-- ++(22mm, 0mm)
-- ++(0mm, -7mm)
-- cycle;
\end{scope}
\begin{scope}[scale=1.2]
\draw
(0,0) to [R=$R$] (2,0)
;
\end{scope}
\end{tikzpicture}
\end{document}




(4,4) to [R=$R$] (6,4)and it got only horizontally centered. I was actually surprised that it worked also for this case, as the drawing does not start in the origin. – Robert Seifert Nov 26 '19 at 07:22circuitikz, right? Yes, one of its authors told me that it does not always work withpics. I cannot say much forcircuitikz, and should have specified that the above applies to TikZ and to some extent topgfplotsbut not tocircuitikz, which redefines certain things, norforest. – Nov 26 '19 at 07:28