Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

How can I modify the orientation of text in the nodes of a mindmap, such that the text is oriented radially from the center in the case of the outermost nodes.

For example, in the below diagram, I seek for the text INSIDE the orange circled nodes to be rotated so that it is in alignment with the direction of the orange lines respectively.

Radial Mindmap

Code for the above mindmap is as follows:

\begin{tikzpicture}
  \path[small mindmap,concept,text=white]
    node[concept] {Bla} [clockwise from=-15]
    child[concept color=red,text=black]{
      node[concept]at(1,0){Bla Bla}[clockwise from=90]
      child[concept color=red!95!black,text=black]{
        node[concept]{A}[clockwise from = 120]
            child {node[concept,scale=0.5] {A.A}}
            child {node[concept,scale=0.5] {A.B}}
            child {node[concept,scale=0.5] {A.C}}
      }
      child[concept color=red!75!black,text=white,grow=50]{
        node[concept]{B}[clockwise from = 80]
            child {node[concept,scale=0.5] {B.A}}
            child {node[concept,scale=0.5] {B.B}}
            child {node[concept,scale=0.5] {B.C}}
      }
      child[concept color=red!50!black,text=white ,grow=10]{
        node[concept]{C}[clockwise from = 40]
            child {node[concept,scale=0.5] {C.A}}
            child {node[concept,scale=0.5] {C.B}}
            child {node[concept,scale=0.5] {C.C}}
      }
      child[concept color=red!25!black,text=white,grow=-30]{
        node[concept]{D}[clockwise from = 0]
            child {node[concept,scale=0.5] {D.A}}
            child {node[concept,scale=0.5] {D.B}}
            child {node[concept,scale=0.5] {D.C}}
      }
      child[concept color=red!10!black,text=white,grow=-70]{
        node[concept]{D}[clockwise from = -40]
            child {node[concept,scale=0.5] {D.A}}
            child {node[concept,scale=0.5] {D.B}}
            child {node[concept,scale=0.5] {D.C}}
      }
    }
    child[concept color=green,text=black, grow=195]{
      node[concept]{Bla Bla}[clockwise from=80]
      child[concept color=green!10!black,text=white]{
        node[concept]{Bla}[counterclockwise from = 50]
            child {node[concept,scale=0.5] {A.A}}
            child {node[concept,scale=0.5] {A.B}}
            child {node[concept,scale=0.5] {A.C}}
      }
      child[concept color=green!25!black,text=white,grow=120]{
        node[concept]{Bla}[counterclockwise from = 90]
            child {node[concept,scale=0.5] {A.A}}
            child {node[concept,scale=0.5] {A.B}}
            child {node[concept,scale=0.5] {A.C}}
      }
      child[concept color=green!50!black,text=white,grow=160]{
        node[concept]{Bla}[counterclockwise from = 130]
            child {node[concept,scale=0.5] {B.A}}
            child {node[concept,scale=0.5] {B.B}}
            child {node[concept,scale=0.5] {B.C}}
      }
      child[concept color=green!75!black,text=white ,grow=200]{
        node[concept]{Bla}[counterclockwise from = 170]
            child {node[concept,scale=0.5] {C.A}}
            child {node[concept,scale=0.5] {C.B}}
            child {node[concept,scale=0.5] {C.C}}
      }
      child[concept color=green!95!black,text=black,grow=240]{
        node[concept]{Bla}[counterclockwise from = 210]
            child {node[concept,scale=0.5] {D.A}}
            child {node[concept,scale=0.5] {D.B}}
            child {node[concept,scale=0.5] {D.C}}
      }
    }
    child[concept color=orange,text=black, grow = -90] {
      node[concept]at(-1.5,-2.5){Bla Bla}[clockwise from=10]
        child[concept color=orange!95!black]{
            node[concept]{Bla}[clockwise from = 40]
                child {node[concept,scale=0.5] {A.A}}
                child {node[concept,scale=0.5] {A.B}}
                child {node[concept,scale=0.5] {A.C}}
        }
        child[concept color=orange!75!black, grow = -30]{
            node[concept]{Bla}[clockwise from =0]
                child {node[concept,scale=0.5] {B.A}}
                child {node[concept,scale=0.5] {B.B}}
                child {node[concept,scale=0.5] {B.C}}
        }
        child[concept color=orange!50!black, text=white, grow=-70]{
            node[concept]{Bla}[clockwise from =-40]
                child {node[concept,scale=0.5] {C.A}}
                child {node[concept,scale=0.5] {C.B}}
                child {node[concept,scale=0.5] {C.C}}
        }
        child[concept color=orange!25!black, text=white, grow=-110]{
            node[concept]{Bla}[clockwise from =-80]
                child {node[concept,scale=0.5] {D.A}}
                child {node[concept,scale=0.5] {D.B}}
                child {node[concept,scale=0.5] {D.C}}
        }
        child[concept color=orange!10!black, text=white, grow=-150]{
            node[concept]{Bla}[clockwise from =-120]
                child {node[concept,scale=0.5] {E.A}}
                child {node[concept,scale=0.5] {E.B}}
                child {node[concept,scale=0.5] {E.C}}
        }
    }    
   ;
\end{tikzpicture}

UPDATE: Continue this topic in Part II, seeking elliptical or rectangular radially rotating nodes.

share|improve this question

1 Answer 1

up vote 28 down vote accepted

There are two and a half problems to solve here.

1. The Mathematical Problem

We have to calculate the amount of rotation.

The counterclockwise from argument is saved internally in \tikz@grow@circle@from@start.

For every child the amount of /tikz/sibling angle get added (counterclockwise) or subtracted (clockwise). The number of the child is saved in \tikznumberofcurrentchild.

For the orange children which are all placed in a clockwise matter the angle the text must be rotated is:

  \tikz@grow@circle@from@start
- (\pgfkeysvalueof{/tikz/sibling angle}) * (\tikznumberofcurrentchild - 1)

¿zʞıʇ

If a node’s content shouldn’t be upside down the formula has to be adjusted:

(
     \tikz@grow@circle@from@start
     - (\pgfkeysvalueof{/tikz/sibling angle}) * (\tikznumberofcurrentchild - 1)
) + 180 * (
      cos(
            \tikz@grow@circle@from@start
          - (\pgfkeysvalueof{/tikz/sibling angle})+(\tikznumberofcurrentchild-1)
      )
      < 0
)

2. The Rotation Problem

Great, so an easy

rotation =   \tikz@grow@circle@from@start
           - (\pgfkeysvalueof{/tikz/sibling angle}) * (\tikznumberofcurrentchild - 1)

should do, right?

Nope:

enter image description here

The whole node gets transformed (in this case: rotated) which means that all anchor nodes are rotated, too. And this confuses the calculation of the circle connection bar decoration. The more we rotate a child the more the connection bar gets twisted.

We surely could adjust the code for the circle connection bar decoration, but that’s a lot of code!

It would be much easier to just rotate the text itself.
With the help of graphicx’s \rotatebox macro this can be easily done:

\newcommand*{\rotateme}[1]{%
    \pgfmathparse{
        \tikz@grow@circle@from@start-
        (\pgfkeysvalueof{/tikz/sibling angle})*(\tikznumberofcurrentchild-1)
    }%
    \rotatebox[origin=c]{\pgfmathresult}{#1}%
}

2½. The Node Text Problem

Do you want to edit every node that should get rotated and add the \rotateme macro?
I didn’t think so!

My solution collects all the node’s text with the help of

  • execute at begin node,
  • execute at and node, and
  • the lrbox environment which saves the node’s text in a box called \rotatenodebox.

This box is then given to the already-mentioned \rotateme macro.

\tikzset{
    conc3/.style={concept,scale=.5},
    orange/.style={
        conc3,
        execute at begin node={\begingroup\begin{lrbox}{\rotatenodebox}},
        execute at end node={\end{lrbox}\rotateme{\usebox\rotatenodebox}\endgroup},
    }
}

Code

\documentclass[tikz]{standalone}
\usetikzlibrary{mindmap}
\newsavebox\rotatenodebox
\makeatletter
\newcommand*{\rotateme}[1]{%
    \pgfmathparse{
        \tikz@grow@circle@from@start-
        (\pgfkeysvalueof{/tikz/sibling angle})*(\tikznumberofcurrentchild-1)
    }%
    \rotatebox[origin=c]{\pgfmathresult}{#1}%
}
\makeatother

\tikzset{
    conc3/.style={concept,scale=.5},
    orange/.style={
        conc3,
        execute at begin node={\begingroup\begin{lrbox}{\rotatenodebox}},
        execute at end node={\end{lrbox}\rotateme{\usebox\rotatenodebox}\endgroup},
    }
}
\begin{document}
\begin{tikzpicture}
  \path[small mindmap,concept,text=white]
    node[concept] {Bla} [clockwise from=-15]
    child[concept color=red,text=black]{
      node[concept]at(1,0){Bla Bla}[clockwise from=90]
      child[concept color=red!95!black,text=black]{
        node[concept]{A}[clockwise from = 120]
            child {node[conc3] {A.A}}
            child {node[conc3] {A.B}}
            child {node[conc3] {A.C}}
      }
      child[concept color=red!75!black,text=white,grow=50]{
        node[concept]{B}[clockwise from = 80]
            child {node[conc3] {B.A}}
            child {node[conc3] {B.B}}
            child {node[conc3] {B.C}}
      }
      child[concept color=red!50!black,text=white ,grow=10]{
        node[concept]{C}[clockwise from = 40]
            child {node[conc3] {C.A}}
            child {node[conc3] {C.B}}
            child {node[conc3] {C.C}}
      }
      child[concept color=red!25!black,text=white,grow=-30]{
        node[concept]{D}[clockwise from = 0]
            child {node[conc3] {D.A}}
            child {node[conc3] {D.B}}
            child {node[conc3] {D.C}}
      }
      child[concept color=red!10!black,text=white,grow=-70]{
        node[concept]{D}[clockwise from = -40]
            child {node[conc3] {D.A}}
            child {node[conc3] {D.B}}
            child {node[conc3] {D.C}}
      }
    }
    child[concept color=green,text=black, grow=195]{
      node[concept]{Bla Bla}[clockwise from=80]
      child[concept color=green!10!black,text=white]{
        node[concept]{Bla}[counterclockwise from = 50]
            child {node[conc3] {A.A}}
            child {node[conc3] {A.B}}
            child {node[conc3] {A.C}}
      }
      child[concept color=green!25!black,text=white,grow=120]{
        node[concept]{Bla}[counterclockwise from = 90]
            child {node[conc3] {A.A}}
            child {node[conc3] {A.B}}
            child {node[conc3] {A.C}}
      }
      child[concept color=green!50!black,text=white,grow=160]{
        node[concept]{Bla}[counterclockwise from = 130]
            child {node[conc3] {B.A}}
            child {node[conc3] {B.B}}
            child {node[conc3] {B.C}}
      }
      child[concept color=green!75!black,text=white ,grow=200]{
        node[concept]{Bla}[counterclockwise from = 170]
            child {node[conc3] {C.A}}
            child {node[conc3] {C.B}}
            child {node[conc3] {C.C}}
      }
      child[concept color=green!95!black,text=black,grow=240]{
        node[concept]{Bla}[counterclockwise from = 210]
            child {node[conc3] {D.A}}
            child {node[conc3] {D.B}}
            child {node[conc3] {D.C}}
      }
    }
    child[concept color=orange,text=black, grow = -90] {
      node[concept]at(-1.5,-2.5){Bla Bla}[clockwise from=10]
        child[concept color=orange!95!black]{
            node[concept]{Bla}[clockwise from = 40]
                child {node[orange] {A.A}}
                child {node[orange] {A.B}}
                child {node[orange] {A.C}}
        }
        child[concept color=orange!75!black, grow = -30]{
            node[concept]{Bla}[clockwise from =0]
                child {node[orange] {B.A}}
                child {node[orange] {B.B}}
                child {node[orange] {B.C}}
        }
        child[concept color=orange!50!black, text=white, grow=-70]{
            node[concept]{Bla}[clockwise from =-40]
                child {node[orange] {C.A}}
                child {node[orange] {C.B}}
                child {node[orange] {C.C}}
        }
        child[concept color=orange!25!black, text=white, grow=-110]{
            node[concept]{Bla}[clockwise from =-80]
                child {node[orange] {D.A}}
                child {node[orange] {D.B}}
                child {node[orange] {D.C}}
        }
        child[concept color=orange!10!black, text=white, grow=-150]{
            node[concept]{Bla}[clockwise from =-120]
                child {node[orange] {E.A}}
                child {node[orange] {E.B}}
                child {node[orange] {E.C}}
        }
    }
   ;
\end{tikzpicture}
\end{document}

Output

enter image description here

share|improve this answer
2  
dude. cool. thanks. legend. –  Nicholas Hamilton Dec 26 '12 at 18:01
    
Crazy! Very impressive. –  Manuel Kuehner Jun 21 at 20:11

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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