There seems to be a weird interaction between the fit package and relative positioning of scopes in tikz, as in, I don't understand why things happen the way they do. Here's my code:


\tikzset{anacat/.style={anchor=north west,minimum height=1.5em,x=.3cm,y=.25cm,every node/.style={scale=0.3}}}
\tikzset{bin/.style={draw=black,anchor=west,text width=3cm}}
  \begin{scope}[shift={(0,0)},local bounding box=Hyy,anacat]
    \node[rotate=90,anchor=north,align=center] at (0,3) {$H\to\gamma\gamma$};
    \node[bin] at (1,0) {low $p_{\textrm{T}t}$};
    \node[bin] at (1,1) {high $p_{\textrm{T}t}$};
    \node[bin] at (1,2) {\acr{VBF} loose (\acr{MVA})};
    \node[bin] at (1,3) {\acr{VBF} tight (\acr{MVA})};
    \node[bin] at (1,4) {\acr{VH} leptonic};
    \node[bin] at (1,5) {$VH$ leptonic};
    \node[bin] at (1,6) {$t\bar{t}H$ leptonic};  
  \node[draw,dotted,fit=(Hyy)] (Hyybox) {};
  %      \begin{scope}[shift={(0,-1)},local bounding box=HZZ,anacat]
  \begin{scope}[shift={(Hyy.south west)},local bounding box=HZZ,anacat]
    \node[rotate=90,anchor=north,align=center] at (0,2) {$H\to ZZ$};
    \node[bin] at (1,0) {ggF $n_{j}=0$};
    \node[bin] at (1,1) {ggF $n_{j}=1$};
    \node[bin] at (1,2) {\acr{VBF} leptonic};
    \node[bin] at (1,3) {\acr{VH} leptonic};
    \node[bin] at (1,4) {\acr{VH} hadronic};
  \node[draw,dotted,fit=(HZZ)] {};
  %      \begin{scope}[shift={(0,-2.15)},local bounding box=HWW,anacat]
  \begin{scope}[shift={(HZZ.south west)},local bounding box=HWW,anacat]
    \node[rotate=90,anchor=north,align=center] at (0,2.5) {$H\to WW$};
    \node[bin] at (1,0) {ggF $n_{j}=0$};
    \node[bin] at (1,1) {ggF $n_{j}=1$};
    \node[bin] at (1,2) {ggF $n_{j}\geq 2$};
    \node[bin] at (1,3) {\acr{VBF} $n_{j}\geq 2$};
    \node[bin] at (1,4) {\acr{WH}};
    \node[bin] at (1,5) {\acr{ZH}};
  \node[draw,dotted,fit=(HWW)] {};
  %      \begin{scope}[shift={(0,-3))},local bounding box=Hbb,anacat]
  \begin{scope}[shift={(HWW.south west)},local bounding box=Hbb,anacat]
    \node[rotate=90,anchor=north,align=center] at (0,2) {$H\to b\bar{b}$};
    \node[bin] at (1,1) {\acr{MVA} low $p_{\textrm{T}^V}$};
    \node[bin] at (1,2) {\acr{MVA} low $p_{\textrm{T}^V}$};
    \node[bin] at (1,3) {$\cdots$};
  \node[draw,dotted,fit=(Hbb)] {};
  %      \begin{scope}[shift={(0,-3.45)},local bounding box=Htt,anacat]
  \begin{scope}[shift={(Hbb.south west)},local bounding box=Htt,anacat]
    \node[rotate=90,anchor=north,align=center] at (0,1) {$H\to \tau\bar{\tau}$};
    \node[bin] at (1,1) {$\cdots$};
  \node[draw,dotted,fit=(Htt)] {};


Here's how I would have expected it to look like (these are the commented-out lines):


Here's how it actually looks like instead:


PS: This is a follow-up question for this one.

  • You can't use anchor=north west to position the scope. It is not a node. Stuff inside it gets placed wherever it would get placed without local bounding box. The local bounding box=Hyy just names whatever the result ends up being. So the style anacat doesn't make much sense to me. – cfr Jun 14 '17 at 3:52
  • the style is mostly to propagate the text height, I can take out the anchor part. but the question how to place scopes relative to each other still remains. – carsten Jun 14 '17 at 7:27
  • But you can't place a scope the way you place a node. You have to place the nodes. You can use something like shift to shift everything in the scope. But you can't treat the scope as a whole. – cfr Jun 14 '17 at 12:29
  • Note that your example is very far from minimal. You only really need 2 scopes with a couple of nodes each to demonstrate the problem. – cfr Jun 14 '17 at 13:06

It is a bit easier if you place nodes relatively. For example, here's a more minimal version of your example. The remainder of the diagram can be completed using the same pattern used for the lower scope here.

  anacat/.style={minimum height=1.5em,x=.3cm,y=.25cm,every node/.style={scale=0.3}},
  bin/.style={draw=black,anchor=west,text width=3cm},
  \begin{scope}[local bounding box=Hyy,anacat]
    \node (p-0) [bin] at (1,0) {low $p_{\textrm{T}t}$};
    \foreach \i [count=\j, remember=\j as \jlast (initially 0)] in {{high $p_{\textrm{T}t}$},{\acr{VBF} loose (\acr{MVA})},{\acr{VBF} tight (\acr{MVA})},{\acr{VH} leptonic},{$VH$ leptonic},{$t\bar{t}H$ leptonic}}
    \node (p-\j) [below=2.5mm of p-\jlast.west, bin] {\i} ;
  \node (p-l) [rotate=90,anchor=south,align=center,yshift=.5mm, scale=.3] at (Hyy.west) {$H\to\gamma\gamma$};
  \node[draw,dotted,fit=(Hyy) (p-l)] (Hyybox) {};
  \begin{scope}[shift=(Hyy.south -| p-0.west),local bounding box=HZZ,anacat]
    %     ;
    \node (q-0) [below=5mm of p-6.west, bin] {ggF $n_{j}=0$};
    \foreach \i [count=\j, remember=\j as \jlast (initially 0)] in {{ggF $n_{j}=1$},{\acr{VBF} leptonic},{\acr{VH} leptonic},{\acr{VH} hadronic}}
    \node (q-\j) [below=2.5mm of q-\jlast.west, bin] {\i} ;
    \node (q-l) [rotate=90,anchor=center,align=center] at (p-l |- HZZ.west) {$H\to ZZ$};
  \node [draw,dotted,fit=(HZZ)] {};

upper and lower scopes

You could also use the chains library, although it is deprecated. (The equivalent involves using the graphs syntax, but it is much less straightforward to use.) However, that library has bugs which won't get fixed due to its status. Nonetheless, chains would simplify the code here by abstracting away from the looping.

Alternatively, you could think of the diagram as a single tree which never branches. Then the trees library, the builtin trees syntax or one of the more specialised packages, such as Forest or tikz-qtree, would be options.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.