12

I tried to add a shade on my mindmap's concepts with

\begin{tikzpicture}[mindmap, text=white,
  every concept/.append style={circle,shading=ball, ball color=black!20!white!20}]

but the problem is that this style is not actually transparent and will fill the concept individual colors. Thus, all concepts will have one single color (defined above).

How to add a shading style over all concepts by reserving the concept individual color?

1 Answer 1

18

To shade a mindmap it is necessary to add a shading to the nodes.

Let's start to add a shading style different for each level; the method used is simple: different concepts will have different ball colors.

The code:

\documentclass[a4paper,11pt]{article}
\usepackage{tikz}
\usetikzlibrary{mindmap}

\tikzset{level 1 concept/.append style={font=\sf, sibling angle=90,level distance = 25mm}}
\tikzset{level 2 concept/.append style={font=\sf, sibling angle=45,level distance = 16mm}}
\tikzset{level 3 concept/.append style={font=\sf, sibling angle=45,level distance = 17mm}}
\tikzset{every node/.append style={scale=0.6}}

\begin{document}
\begin{tikzpicture}[mindmap, concept color=blue, font=\sf\bf, text=white]
\node[concept,ball color=blue]{Root Concept}[clockwise from=315]
 child [concept color=violet] {node[circle,ball color=violet] (c1){Child 1}                                
      child  {node [circle,ball color=violet](c11){Child 1-1}}
      child  {node [circle,ball color=violet](c12){Child 1-2}}
      child  {node [circle,ball color=violet](c13){Child 1-3}}                                                   
 }
 child [concept color=orange]{node [circle,ball color=orange](c2){Child 2}
     child {node [circle,ball color=orange](c21){Child 2-1}}
     child {node [circle,ball color=orange](c22){Child 2-2}}
     child {node [circle,ball color=orange](c22){Child 1-3}}
 };
\end{tikzpicture}
\end{document}

The result is:

enter image description here

Now we can start to define much complicated shadings to differentiate concepts (related answers as reference for shading: How to create a ball shading and to customize 3D lighting manually? and Is there a way to tune ball shading in TikZ ?); let's define, for example a myball shading as:

\makeatletter
\pgfdeclareradialshading[tikz@ball]{myball}{\pgfqpoint{5bp}{10bp}}{%
 color(0bp)=(tikz@ball!30!white);
 color(9bp)=(tikz@ball!75!white);
 color(18bp)=(tikz@ball!90!black);
 color(25bp)=(tikz@ball!70!black);
 color(50bp)=(black)}
\makeatother

With this definition, however, it is not possible to change color easily; that's why we need also:

\tikzoption{myball color}{\pgfutil@colorlet{tikz@ball}{#1}\def\tikz@shading{myball}\tikz@addmode{\tikz@mode@shadetrue}}

to subsequently call myball color=....

Here is the full example:

\documentclass[a4paper,11pt]{article}
\usepackage{tikz}
\usetikzlibrary{mindmap}

\makeatletter

\pgfdeclareradialshading[tikz@ball]{myball}{\pgfqpoint{5bp}{10bp}}{%
 color(0bp)=(tikz@ball!30!white);
 color(9bp)=(tikz@ball!75!white);
 color(18bp)=(tikz@ball!90!black);
 color(25bp)=(tikz@ball!70!black);
 color(50bp)=(black)}

 % to make possible use "myball color=..." 
\tikzoption{myball color}{\pgfutil@colorlet{tikz@ball}{#1}\def\tikz@shading{myball}\tikz@addmode{\tikz@mode@shadetrue}}

 \pgfdeclareradialshading[tikz@ball]{myball-left}{\pgfqpoint{5bp}{-9bp}}{%
 color(0bp)=(tikz@ball!30!white);
 color(15bp)=(tikz@ball!75!white);
 color(25bp)=(tikz@ball!90!black);
 color(40bp)=(tikz@ball!70!black);
 color(70bp)=(black)}

\tikzoption{myball-left color}{\pgfutil@colorlet{tikz@ball}{#1}\def\tikz@shading{myball-left}\tikz@addmode{\tikz@mode@shadetrue}}

\pgfdeclareradialshading[tikz@ball]{myball-right}{\pgfqpoint{-5bp}{-9bp}}{%
 color(0bp)=(tikz@ball!30!white);
 color(15bp)=(tikz@ball!75!white);
 color(25bp)=(tikz@ball!90!black);
 color(40bp)=(tikz@ball!70!black);
 color(70bp)=(black)} 

\tikzoption{myball-right color}{\pgfutil@colorlet{tikz@ball}{#1}\def\tikz@shading{myball-right}\tikz@addmode{\tikz@mode@shadetrue}}

\makeatother

\tikzset{level 1 concept/.append style={font=\sf, sibling angle=90,level distance = 25mm}}
\tikzset{level 2 concept/.append style={font=\sf, sibling angle=45,level distance = 16mm}}
\tikzset{level 3 concept/.append style={font=\sf, sibling angle=45,level distance = 17mm}}
\tikzset{every node/.append style={scale=0.6}}


\begin{document}
\begin{tikzpicture}[mindmap, concept color=blue, font=\sf\bf, text=white]
\node[concept,shading=myball]{Root Concept}[clockwise from=315]
    child [concept color=orange] {node[circle, myball-left color=orange] (c1){Child 1}                                
        child  {node [circle, myball-left color=orange](c11){Child 1-1}}
        child  {node [circle,myball-left color=orange](c12){Child 1-2}}
        child  {node [circle,myball-left color=orange](c13){Child 1-3}}                                                   
     }
     child [concept color=violet]{node [circle,myball-right color=violet](c2){Child 2}
        child {node [circle,myball-right color=violet](c21){Child 2-1}}
        child {node [circle,myball-right color=violet](c22){Child 2-2}}
        child {node [circle,myball-right color=violet](c22){Child 1-3}}
    };
\end{tikzpicture}
\end{document}

which gives:

enter image description here

Some remarks

  1. A typical call is: child {node [circle, myball-left color=orange](c11){Child 1-1}} where circle is absolutely needed otherwise the concept will be a square.

  2. If you try to add concept to the node options, your ball will circled (the effect is more evident when the circle size is small).

In the previous example change the document into:

\begin{document}
\begin{tikzpicture}[mindmap, concept color=blue, font=\sf\bf, text=white]
\node[concept,shading=myball]{Root Concept}[clockwise from=315]
    child [concept color=orange] {node[concept,circle, myball-left color=orange] (c1){Child 1}                                
        child  {node [concept,circle, myball-left color=orange](c11){Child 1-1}}
        child  {node [concept,circle,myball-left color=orange](c12){Child 1-2}}
        child  {node [concept,circle,myball-left color=orange](c13){Child 1-3}}                                                   
     }
     child [concept color=violet]{node [concept,circle,myball-right color=violet](c2){Child 2}
        child {node [concept,circle,myball-right color=violet](c21){Child 2-1}}
        child {node [concept,circle,myball-right color=violet](c22){Child 2-2}}
        child {node [concept,circle,myball-right color=violet](c22){Child 1-3}}
    };
\end{tikzpicture}
\end{document}

This leads to:

enter image description here

Notice the external circle, very evident in the orange concepts.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .