2

I'm pretty new to Tikz. How can I draw the below graph in Tikz?system

I will break up my questions into small pieces.

  1. How can I group a bunch of objects and form a big one?
  2. How can I zoom an object and place detailed objects into the zoomed container?
  3. How to draw a human figure?
  4. How to scatter objects inside a container without predefined placement info?

Any help is much appreciated!

Amos
  • 145

1 Answers1

4

This is too complicated for a comment. It is based on Gregor Perčič's solution.

First, you can simplify drawing rectangles. Second, using a scope you can move a group of objects around using the shift key, and create a node (more or less) using the local bounding box key.

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{fit,positioning}

\begin{document}
\begin{tikzpicture}

\begin{scope}[shift={(1,1)},local bounding box=A]
\draw (0,0) rectangle (11.3,1.5);
\draw (0.2,0.2) rectangle (3.2,1);
\draw (3.7,0.2) rectangle (6.7,1);
\draw (7.2,0.2) rectangle (10.2,1);
\node[scale=0.8] at (1.65,0.5) {$S_{x_{1}}$};
\node[scale=0.8] at (5.5,0.5) {$S_{x_{2}}$};
\node[scale=0.8] at (8.5,0.5) {$S_{x_{3}}$};
\node[scale=0.8] at (10.65,0.5) {$S_{x}$};
\end{scope}

\draw[->] (0,0) -- (A.west);
\end{tikzpicture}
\end{document}
John Kormylo
  • 79,712
  • 3
  • 50
  • 120
  • Ah, this is nice. Can I add some randomization to inner rectangles placement? – Amos Mar 16 '17 at 16:44
  • I'm actually somewhat ashamed that I couldn't find a better way to construct the diagram. I've been using Tikz for a long time, but for this example, it seems to me, there isn't any witty solution. John, can you perhaps help me improve my Tikz skills? I'd be grateful. – God bless Mar 16 '17 at 17:05
  • @GregorPerčič - It is not unusual to ask questions here about better ways of doing things. That is how I learned a lot of useful tricks. – John Kormylo Mar 16 '17 at 21:37