3

When using this code:

\documentclass[tikz,border=5]{standalone}
\usetikzlibrary{trees,mindmap}

\tikzset{grow cyclic list/.code={%
  \def\tikzgrowthpositions{{#1}}%
  \foreach \n [count=\i,remember=\i]in {#1}{}%
  \let\tikzgrowthpositionscount=\i%
  \tikzset{growth function=\tikzgrowcycliclist}}}
\def\tikzgrowcycliclist{%
  \pgftransformshift{%
    \pgfpointpolar{\tikzgrowthpositions[mod(\the\tikznumberofcurrentchild-1,\tikzgrowthpositionscount)]}%
      {\the\tikzleveldistance}}}

\tikzset{every node/.style={font={\fontsize{12pt}{14pt}\selectfont}}}

\begin{document}

\begin{tikzpicture}[mindmap, concept color=blue!20, every child node/.style={concept}]

\path node[concept] {Mathematical Modeling and Machine Learning} [grow cyclic list={90,50,0}]
    child { node {clustering} [grow cyclic list={110,55}]
        child { node {K-means} }
        child { node {hie\-rar\-chi\-cal clustering} }
    }
    child { node {dimension reduction} [clockwise from=50]
        child { node {PCA} }
    }
    child[level distance=10cm] { node {regression} [grow cyclic list={135,90,45,0}]
        child { node {training} [grow cyclic list={180,135,90}]
            child { node {least squares} }
            child { node {linear least squares} }
            child { node {regression to the mean} }
        }
        child[level distance=5cm] { node {diagnostics} [grow cyclic list={135,90,45}]
            child[level distance=4cm] { node {re\-si\-duals, residual variance} }
            child { node {variance inflation} }
            child[level distance=4cm] { node {va\-rian\-ces and quasi likelihood} }
        }
        child[level distance=10cm] { node {model search, comparison and selection} }
        child[level distance=10cm] { node {multivariable regression}
            child { node {multivariable simulation} }
            child { node {dummy variables} }
            child { node {interactions} }
            child { node {interpreting coefficients} }
        }
    }
;

\end{tikzpicture}
\end{document}

and I comment the line \tikzset{every node/.style={font={\fontsize{12pt}{14pt}\selectfont}}}

I get nice concepts with

enter image description here

but if I use the 12pt font I get

enter image description here

Check out the bubble with the text "va-rian-ces and quasi likelihood". What can I do to have the text nicely formatted in the concept, but with a 12pt font?

4

If the document font is not 12pt, as would usually be the case if you are using it in diagrams, you can set it for that particular diagram. But you should set it for the entire diagram so that the map is appropriately configured.

For example:

\documentclass[tikz,border=5]{standalone}
\usetikzlibrary{mindmap}

\tikzset{grow cyclic list/.code={%
  \def\tikzgrowthpositions{{#1}}%
  \foreach \n [count=\i,remember=\i]in {#1}{}%
  \let\tikzgrowthpositionscount=\i%
  \tikzset{growth function=\tikzgrowcycliclist}}}
\def\tikzgrowcycliclist{%
  \pgftransformshift{%
    \pgfpointpolar{\tikzgrowthpositions[mod(\the\tikznumberofcurrentchild-1,\tikzgrowthpositionscount)]}%
      {\the\tikzleveldistance}}}

\begin{document}
{\fontsize{12pt}{14pt}\selectfont
\begin{tikzpicture}[mindmap, concept color=blue!20, every child node/.style={concept}]

\path node[concept] {Mathematical Modeling and Machine Learning} [grow cyclic list={90,50,0}]
    child { node {clustering} [grow cyclic list={110,55}]
        child { node {K-means} }
        child { node {hie\-rar\-chi\-cal clustering} }
    }
    child { node {dimension reduction} [clockwise from=50]
        child { node {PCA} }
    }
    child[level distance=10cm] { node {regression} [grow cyclic list={135,90,45,0}]
        child { node {training} [grow cyclic list={180,135,90}]
            child { node {least squares} }
            child { node {linear least squares} }
            child { node {regression to the mean} }
        }
        child[level distance=5cm] { node {diagnostics} [grow cyclic list={135,90,45}]
            child[level distance=4cm] { node {re\-si\-duals, residual variance} }
            child { node {variance inflation} }
            child[level distance=4cm] { node {va\-rian\-ces and quasi likelihood} }
        }
        child[level distance=10cm] { node {model search, comparison and selection} }
        child[level distance=10cm] { node {multivariable regression}
            child { node {multivariable simulation} }
            child { node {dummy variables} }
            child { node {interactions} }
            child { node {interpreting coefficients} }
        }
    }
;

\end{tikzpicture}}
\end{document}

12pt map

Note that the settings of the map are configured by default to use smaller fonts for nodes which are more steps from the root. If you don't want this, you need to override the default style for the nodes of whichever levels you need to change. Simply changing the font size isn't enough because the node size etc. would also need to be adjusted to get a reasonable result.

Here are the relevant default settings of the styles for the various levels. (The library has not, apparently, been updated to use the current syntax and still uses the deprecated \tikzstyle.)

% default settings copied from tikzlibrarymindmap.code.tex 

\tikzstyle{root concept}=   [minimum size=4cm,text width=3.5cm,font=\pgfutil@font@large]
\tikzstyle{level 1 concept}=[minimum size=2.25cm,
                             level distance=5cm,
                             text width=2cm,
                             sibling angle=60,
                             font=\pgfutil@font@small]
\tikzstyle{level 2 concept}=[minimum size=1.75cm,%
                             level distance=2.9cm,%
                             text width=1.5cm,%
                             sibling angle=60,%
                             font=\pgfutil@font@footnotesize]
\tikzstyle{level 3 concept}=[minimum size=1.15cm,%
                             text width=1cm,%
                             level distance=2.4cm,%
                             sibling angle=30,%
                             font=\pgfutil@font@tiny]
\tikzstyle{level 4 concept}=[minimum size=0.9cm,%
                             text width=0.7cm,
                             level distance=1.85cm,%
                             sibling angle=30,%
                             font=\pgfutil@font@tiny]

What happens if you typeset 12pt text in a level 3 node is, therefore, what happens if you typeset 12pt text in any box of width 1cm: it does not fit at all nicely!

So more extensive changes are required to produce reasonable results. For example:

\documentclass[tikz,border=5,12pt]{standalone}
\usetikzlibrary{mindmap}

\tikzset{grow cyclic list/.code={%
  \def\tikzgrowthpositions{{#1}}%
  \foreach \n [count=\i,remember=\i]in {#1}{}%
  \let\tikzgrowthpositionscount=\i%
  \tikzset{growth function=\tikzgrowcycliclist}}}
\def\tikzgrowcycliclist{%
  \pgftransformshift{%
    \pgfpointpolar{\tikzgrowthpositions[mod(\the\tikznumberofcurrentchild-1,\tikzgrowthpositionscount)]}%
      {\the\tikzleveldistance}}}
\begin{document}
  \begin{tikzpicture}[
    mindmap,
    every node/.append style={execute at begin node=\hskip0pt},
    level 1 concept/.append style={font=\normalsize},
    level 2 concept/.append style={
      font=\normalsize,
      minimum size=2.25cm,
      text width=2cm,
      sibling angle=60,
      level distance=3.5cm,
    },
    level 3 concept/.append style={
      font=\normalsize,
      minimum size=2cm,
      text width=1.75cm,
      sibling angle=60,
      level distance=3.25cm
    },
    concept color=blue!20,
    every child node/.style={concept}
  ]

\path node[concept] {Mathematical Modeling and Machine Learning} [grow cyclic list={110,70,0}]
    child { node {clustering} [grow cyclic list={110,55}]
        child { node {K-means} }
        child { node {hierarchical clustering} }
    }
    child { node {dimension reduction} [clockwise from=50]
        child { node {PCA} }
    }
    child[level distance=10cm] { node {regression} [grow cyclic list={135,75,40,0}]
        child { node {training} [grow cyclic list={180,135,90}]
            child { node {least squares} }
            child { node {linear least squares} }
            child { node {regression to the mean} }
        }
        child[level distance=5cm] { node {diagnostics} [grow cyclic list={125,90,45}]
            child[level distance=4cm] { node {residuals, residual variance} }
            child { node {variance inflation} }
            child[level distance=4cm] { node {variances and quasi likelihood} }
        }
        child[level distance=10cm] { node {model search, comparison and selection} }
        child[level distance=10cm] { node {multivariable regression}
            child { node {multivariable simulation} }
            child { node {dummy variables} }
            child { node {interactions} }
            child { node {interpreting coefficients} }
        }
    }
;
\end{tikzpicture}
\end{document}

produces

12pt in all nodes

  • Thanks. This was not yet quite enough in my case, so I used small/.style = {text width=1.25cm, level distance=2.4cm, sibling angle=35 }, large/.style = { text width=2cm, level distance=4cm }, and a couple more, but this combined with adjusting the levels, combined with some exclusive handling of some especially difficult concepts, I formatted my mindmaps nicely. – Make42 Dec 8 '15 at 11:48
  • What I don't get: Why do you want me to put the \fontsize{12pt}{14pt}\selectfont outside and not within a every node/.style? – Make42 Dec 8 '15 at 11:50
  • If you put it outside the tikzpicture, it changes the sizing of the diagram generally and not just the content of the nodes. Also, by default, different size text is used in different levels of the map. If you put the size within each node, you override that so that you end up with larger text than you would otherwise and there's not room for it unless you adjust the sizes of the nodes generally. – cfr Dec 8 '15 at 13:14

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.