4

I am trying to express this diagram with a circular sequence: enter image description here

I tried with the following codes, however I do not know how to fill different slices with different colors (three different shades of grey would be better than green, blue and yellow). Moreover I do not know how to fit the texts in the slices, Could you please help me with that? Thank you in advance :)

\documentclass{article}
\usepackage{xstring,tikz}
\newcommand*\GetListMember[2]{\StrBetween[#2,\number\numexpr#2+1]{,#1,},,\par}%
\newlength{\MidRadius}
\newcommand*{\CircularSequence}[3]{%
% #1 = outer circle radius
% #2 = inner circle radius
% #3 = seqeunce
\StrCount{#3}{,}[\NumberOfElements]
\pgfmathsetmacro{\AngleSep}{360/(\NumberOfElements+1)}
\pgfmathsetlength{\MidRadius}{(#1+#2)/2}
\draw [black,  ultra thick] circle (#2);
\draw [black, ultra thick] circle (#1);
\foreach [count = \Count] \Angle in {0,\AngleSep,..., 360} {%
    \draw [gray, ultra thick] (\Angle:#2) -- (\Angle:#1);
    \pgfmathsetmacro{\MidPoint}{\Angle+\AngleSep/2}
    \node at (\MidPoint:\MidRadius) {\GetListMember{#3}{\Count}};
}%
}%
\begin{document}
\begin{tikzpicture}
\centering
\CircularSequence{6.0cm}{4.cm}{Liquidity Risk,Counterparty Risks,Management     Risks,Corporate Governance Risk,Legal \& Regulatory Risks,Political and Social Risks,System Risk,Business Risks,Market Risks}
\end{tikzpicture}
\end{document}
1

1 Answer 1

4

To fit the text into the slices, you can set text width=2cm,align=center for the appropriate \node.

There are likely many ways of doing the colors, one possibility is shown in the code below. Note that I rewrote the loop a bit. One thing I did was make a coordinate at each "inner" corner of the tiles, which I use later.

The inner slices are made in a more manual fashion. No shading, because I don't know how.

\documentclass{article}
\usepackage{xstring,tikz}
\usetikzlibrary{backgrounds}
\newcommand*\GetListMember[2]{\StrBetween[#2,\number\numexpr#2+1]{,#1,},,\par}%
\newlength{\MidRadius}
\newcommand*{\CircularSequence}[3]{%
% #1 = outer circle radius
% #2 = inner circle radius
% #3 = seqeunce
\StrCount{#3}{,}[\NumberOfElements]
\pgfmathtruncatemacro\NumberOfElements{\NumberOfElements+1}
\pgfmathsetmacro{\AngleSep}{360/(\NumberOfElements)}
\pgfmathsetlength{\MidRadius}{(#1+#2)/2}
\draw [black,  ultra thick] circle (#2);
\draw [black, ultra thick] circle (#1);
\foreach [evaluate=\Count as \Angle using (\Count-1)*\AngleSep] \Count in {1,...,\NumberOfElements} {%
    \ifnum\Count>6
        \edef\myclr{black!40} % color for element 7-9
    \else
       \ifnum\Count>2
          \edef\myclr{black!25} %color for element 3-6
       \else
          \edef\myclr{black!10} % color for element 1-2
    \fi\fi

    %fill the slice
    \fill [\myclr] (\Angle:#2) coordinate (i-\Count) -- (\Angle:#1) arc[start angle=\Angle,delta angle=\AngleSep,radius=#1] -- (\Angle+\AngleSep:#2) arc[start angle=\Angle+\AngleSep,end angle=\Angle,radius=#2];
    % draw the separator
    \draw [gray, ultra thick] (\Angle:#2) -- (\Angle:#1);
    \pgfmathsetmacro{\MidPoint}{\Angle+\AngleSep/2}
    \node [text width=2cm,align=center] at (\MidPoint:\MidRadius) {\GetListMember{#3}{\Count}};
}%
}%
\begin{document}
\begin{tikzpicture}
\centering
\CircularSequence{6.0cm}{4.cm}{Liquidity Risk,Counterparty Risks,Management     Risks,Corporate Governance Risk,Legal \& Regulatory Risks,Political and Social Risks,System Risk,Business Risks,Market Risks}

\begin{scope}[on background layer]
\foreach \clr/\txt/\txtang/\starti/\stopi in {%
black!15/Financial risk/50/1/3,%
black!30/Strategic risk/-70/3/7,%
black!45/Operational risk/-30/7/1%
} 
{
\pgfmathsetmacro\startangle{(\starti-1)*360/9}
\pgfmathsetmacro\stopangle{(\stopi-1)*360/9}
\pgfmathsetmacro\deltaangle{ifthenelse(\stopangle-\startangle<0,\stopangle-\startangle+360,\stopangle-\startangle)}
\pgfmathsetmacro\textangle{\startangle+0.5*\deltaangle}
\fill [\clr] (i-\starti) -- ++({\startangle+180}:1cm) arc[start angle=\startangle,delta angle=\deltaangle,radius=3cm] -- (i-\stopi) arc[start angle=\stopangle,delta angle=-\deltaangle,radius=4cm];
\node [rotate=-\txtang] at (\textangle:3.4cm) {\txt};
}
\end{scope}
\end{tikzpicture}
\end{document}

enter image description here

3
  • Thank you so much! But how about the inside circular sequence? I mean operational, strategic and financial risks.
    – rjkvc
    Mar 22, 2017 at 13:26
  • @rjkvc Ah, you didn't ask specifically about it, so I left that out. I can't do the fading, but I can probably do the rest. Will edit later, and ping you when I've done that. Mar 22, 2017 at 15:19
  • @rjkvc See updated answer. Mar 22, 2017 at 15:49

You must log in to answer this question.

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