Positioning a tikz scope relative to another tikz scope
Here is a solution using local bounding box
to get the bounding box of the first scope and using shift
to define the origin of the second scope:
\documentclass[tikz]{standalone}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
\begin{scope}[local bounding box=scope1]
\draw (2,2) rectangle (3,4);
\end{scope}
\begin{scope}[shift={($(scope1.east)+(1cm,0)$)}]
\draw (0,0) rectangle (2,1);
\end{scope}
\end{tikzpicture}
\end{document}
Edit: the answer below is here for reference but note that nesting tikzpictures is discouraged due to some subtle side-effects that this may cause.
In most cases, to build a "modular" picture you can use the pic
action documented in Chapter 18 of the documentation. In simpler cases like the one in the question, a combination of shift
and fit
usually suffices.
If you need to keep the two scopes separated and wish to use them as "modules" I would suggest you use two nodes with nested tikzpictures as in
\begin{tikzpicture}
\node(scope1){
\begin{tikzpicture}
\draw (1,2) rectangle (3,4);
\end{tikzpicture}
};
\node[at={($(scope1.east)+(1cm,0)$)},anchor=west] (scope2){
\begin{tikzpicture}
\draw (5,6) rectangle (7,8);
\end{tikzpicture}
};
\end{tikzpicture}