3

I would like to make a mindmap and connect each leaf with an outside node. How can I do this?

In the following example I'd like to connect each

Example code:

\tikzset{
        top concept/.style = {mindmap, concept color=orange},
        is6/.style = {concept},
        to6/.style = {concept},
        isConc/.style = {concept},
        toConc/.style = {concept}
}

\begin{tikzpicture}

\node[circle,draw] (thatnode) at (10,0)  {that other node};

\path[top concept] (0,20cm) node[isConc, insert path={circle[fill=red,radius=5cm]}] {Statistic} [clockwise from=0]
    child[toConc] { node[isConc] {general theory}
        child[to6] { node[is6] {intro to propability} }
        child[to6] { node[is6] {asymptotics and Law of large number} }
        child[to6] { node[is6] {asymptotics and Central Limit Theorem} }
    }
    child[toConc] { node[isConc] {distributions} [clockwise from=90]
        child[to6] { node[is6] {binomial distrubtion} }
        child[to6] { node[is6] {normal distribution} }
        child[to6] { node[is6] {poisson distribution} }
    }  
    child[toConc] { node[isConc] {statistics} [clockwise from=-30]
        child[to6] { node[is6] {variability, variance} }
        child[to6] { node[is6] {expected value} }
    }
    child[toConc] { node[isConc] {propability}
        child[to6] { node[is6] {propability mass functions} }
        child[to6] { node[is6] {propability density functions} }
        child[to6] { node[is6] {baye's rule} }
        child[to6] { node[is6] {independence} }
    }
    child[toConc] { node[isConc] {hypothesis testing}
        child[to6] { node[is6] {standard error of mean} }
        child[to6] { node[is6] {T confidence intervals} }
        child[to6] { node[is6] {T tests} }
        child[to6] { node[is6] {hypothesis testing} }
        child[to6] { node[is6] {two group testing} }
        child[to6] { node[is6] {pvalues} }
        child[to6] { node[is6] {power} } % (propability of rejecting null hypothesis when false)
        child[to6] { node[is6] {bootstrapping} }
        child[to6] { node[is6] {permutation tests} }
    }
;
\end{tikzpicture}

I thought about something along those lines:

\tikzset{
        is6/.style = {concept, concept color=col6, alias=this, append after command={(this) -- (thatnode)}},
        to6/.style = {concept, concept color=colI!50!col6},
}

Small working example:

I'd like to get the (this) -- (othernode) into the style.

\documentclass[a4paper,10pt]{article} \usepackage[utf8]{inputenc} \usepackage{tikz} \usetikzlibrary{shapes,arrows,chains,positioning,calc,trees,mindmap}

\tikzset{ is6/.style = {concept, concept color=green, text=black, alias=this}, to6/.style={concept}, isConc/.style={concept, color=orange, text=black}, toConc/.style={concept, text=black}}

\begin{document}

\begin{tikzpicture} \node[fill=red, circle] (othernode) at (7,7) {adsf}; \path[mindmap, concept, color=orange] (0,0cm) node[isConc] {Statistic} [clockwise from=90]     child[toConc] { node[isConc] {general theory}       child[to6] { node[is6] {intro}  (this) -- (othernode) }         child[to6] { node[is6] {outro} (this)  -- (othernode) }     }   child[toConc] { node[isConc] {distributions} [clockwise from=0]         child[to6] { node[is6] {binomial}  (this) -- (othernode)  }         child[to6] { node[is6] {normal} (this)  -- (othernode)  }   }   ;

\end{tikzpicture}

\end{document}

Btw. Tikz \draw as part of style (Drawing something inside each node of certain type) is not the same ;-).

Make42
  • 1,772
  • Could you please complete your code so we can compile it? – cfr Dec 01 '15 at 20:25
  • If your nodes have regular names, you can just use a loop at the end of the map to join them up. I'd demonstrate if I had a working example but I don't have time for guessing games at the minute. – cfr Dec 01 '15 at 20:27
  • @cfr: Here you are :-). – Make42 Dec 01 '15 at 22:42
  • I meant that, if you named the nodes, you could loop over them at the end of the map to join them to whatever node. But that wouldn't make it part of a style you could apply to the node because the node's a node. – cfr Dec 01 '15 at 23:58
  • @cfr: But then I would have to name each node with a different name (right?) and in my real application I hava LOT of them. Also: How can I loop over them? I would have to put them in an array or something like that (right?) - how would I do that? – Make42 Dec 02 '15 at 09:34

1 Answers1

5

If othernode is defined before drawing the mindmap, you can use a \pgfextra command inside style to draw a link between mindmap nodes and othernode.

\documentclass[a4paper,10pt]{article} 
\usepackage[utf8]{inputenc} 
\usepackage{tikz} 
\usetikzlibrary{shapes,arrows,chains,positioning,calc,trees,mindmap}

\tikzset{
    is6/.style = {concept, concept color=green, 
                        text=black, alias=this,
                        append after command={
                        \pgfextra{
                            \draw[red,dashed] (this)--(othernode);}
                            }}, 
    to6/.style={concept}, 
    isConc/.style={concept, color=orange, text=black}, 
    toConc/.style={concept, text=black}}

\begin{document}

\begin{tikzpicture} 
\node[fill=red, circle] (othernode) at (7,7) {adsf}; 
\path[mindmap, concept, color=orange] (0,0cm) 
node[isConc] {Statistic} [clockwise from=90]        
    child[toConc]{node[isConc] {general theory}       
            child[to6] {node[is6] {intro}}         
            child[to6] {node[is6] {outro}}}   
    child[toConc] {node[isConc] {distributions} [clockwise from=0]                  
            child[to6] {node[is6] {binomial}}         
            child[to6] {node[is6] {normal}}   
            };
\end{tikzpicture}

\end{document}

enter image description here

Ignasi
  • 136,588
  • I understand what \pgfextra does, but I am not sure I understand what append after command. I understood that the reason, by usage of append after command did not work is, because it appended the code after the construction of the path (so just before ;). Why then would \pgfextra help? I'd expect that \pgfextra would just be appended after the construction of the path, which - again - would be useless in my case. So why does it work? – Make42 Dec 02 '15 at 09:50
  • @user49283 I also don't deeply understand how it works but \pgfextra interrupts the path construction and starts a new one, when it finishes the interrupted continues. This is the reason why \draw or \path are needed inside a \pgfextra command. A regular append after command uses the still not finished \path command to complete its task. Does it helps you? – Ignasi Dec 02 '15 at 10:00
  • Now my bubbles have a dashed line around them... e.g. around the green bubbles is a green dashed circle... how do I get rid of it? 2) ALSO: I want the lines to be underneath the bubbles: How do I do that?
  • – Make42 Dec 02 '15 at 10:03
  • regarding the path interruption: I get the path interruption, but I don't get what is considered a "command" from "append after command". Was I wrong to assume it is the path? Is it the node? What code is the code appended to? – Make42 Dec 02 '15 at 10:06
  • @user49283 Not sure to understand your last comments but \path doesn't "draw" just places objects and append after command inside it does the same. But append after command=\pgfextra{\draw ... inside a path command interrupts path and stars a \draw-ing command. – Ignasi Dec 02 '15 at 10:19
  • Well, I thought that append after command puts its argument just before ; in path ... ;, but it seems I misunderstood the manual. It is put after the respective node: "Some of the path commands described in the following sections take optional arguments. For these commands, when you use this key inside these options, the path will be inserted after the path command is done. For instance, when you give this command in the option list of a node, the path will be added after the node." – Make42 Dec 02 '15 at 10:38
  • Can you answer: 1) Now my bubbles have a dashed line around them... e.g. around the green bubbles is a green dashed circle... how do I get rid of it? 2) ALSO: I want the lines to be underneath the bubbles: How do I do that? – Make42 Dec 02 '15 at 10:40
  • @user49283 1) i don't see dashed lines around bubles with my code, what's different from yours? 2) add backgrounds library and draw extra line on background layer with append after command=\pgfextra{\begin{scope}[on background layer] ... \end{scope}} – Ignasi Dec 02 '15 at 10:45
  • This does not work: I am using tikzposter (and in that I'm using a \block and in that \begin{tikzpicture}) and the stuff in \begin{scope}[on background layer] ... \end{scope} is not transfered to the background of \begin{tikzpicture} but to the background of the poster. – Make42 Dec 02 '15 at 11:39
  • @user49283 You need to provide a proper minimal example in your question. Although this sounds to me more like a follow-up. This answer answers the question when your code is completed in a standard way. It just doesn't answer it when your code is completed in a non-standard way which was never specified in the question. You can declare additional layers and put the dashed lines on a layer above the background but below the main layer. – cfr Dec 02 '15 at 13:27
  • @user49283 As cfr pointed, your minimal example was not enough representative for your problem. But as your original question has been solved (I think so), you could write a new one showing your real environment. – Ignasi Dec 02 '15 at 16:04