Atualizar

Atualizar

"Sunburst Chart - também conhecido como Ring Chart, Multi-level Pie Chart e Radial Treemap - é normalmente usado para visualizar estruturas de dados hierárquicas."

O que procuro não é exatamente o que foi dito acima, mas uma generalização dele.

Eu gostaria de criar um enredo simples para um artigo.

Devem ser gráficos vetoriais e fáceis de criar.

Gostaria de adicionar texto dentro dos componentes, se possível.

Existem pelo menos duas opções aqui (veja abaixo). Talvez também fosse possível expressar isso como uma espécie de 'redemoinho', se é que você me entende...

Também seria ótimo se eu pudesse enfatizar as sobreposições dos componentes, ou seja, através de um gráfico de pizza explodindo com sobreposições.

insira a descrição da imagem aqui

Responder1

Suponho que isso poderia ser chamado degráfico anular, mais ou menos como gráficos de linhagem circulares, a partir dos quais este projeto cresceu. Isso deve começar. O ambiente envolvente é onione leva um argumento, a espessura dos anéis (a estrela faz com que os eixos xy sejam desenhados). A \annulusmacro leva três argumentos obrigatórios: o número da camada (o mais interno é 0), o ângulo inicial e o ângulo final, sendo os ângulos especificados no sentido anti-horário. Há também um argumento opcional no início para a cor de preenchimento e no final para o texto. Um comando completo pode ser assim:

\annulus[purple!20]{2}{165}{325}[more\\stuff](veja o código abaixo).

Nada muito complicado aqui. O TikA função Z arcfaz a maior parte do trabalho.

\documentclass{article}

\usepackage{xcolor}
\usepackage{xparse}
\usepackage{tikz}


\usetikzlibrary{calc,positioning}

%% |=====8><-----| %%

\newlength{\layerwd}
\newcounter{outermost}

%% |=====8><-----| %%

\NewDocumentEnvironment{onion}{sm}{%*= draw axes; #1: thickness of each annulus
    \begin{tikzpicture}
        \setlength{\layerwd}{#2}%
        \setcounter{outermost}{0}
        \IfBooleanT{#1}{%
            \draw[<->] (-4,0) -- (4,0);
            \draw[<->] (0,4) -- (0,-4);
        }
}{%
    \foreach \A in {0,...,\theoutermost}{\draw[thick] (0,0) circle (\A*\layerwd+\layerwd);}
    \end{tikzpicture}
}

% *=unused; [optional fill color]; #3 layer; #4 start angle; #5 stop angle; #6 [optional text]
%% angles are counterclockwise in degrees
\NewDocumentCommand{\annulus}{sO{lightgray}mmmo}{%
    \filldraw[thick,fill=#2] (#4:#3*\layerwd) %% start here
        arc [radius=#3*\layerwd, start angle=#4, delta angle=#5-#4] %% inner arc
        -- (#5:#3*\layerwd+\layerwd) %% move out
        arc [radius=#3*\layerwd+\layerwd, start angle=#5, delta angle=#4-#5] %% outer arc
        -- cycle; %% Back to the beginnning
    \pgfmathsetmacro{\tmp}{(#5-#4)/2 +#4} %% Locate the middle of the arc
    \IfNoValueF{#6}{\node[inner sep=0pt, %%% If there is text, print it
        text width=#3*\layerwd*3+\layerwd,
        align=center,
        rotate=\tmp-90,
        font=\footnotesize] at (\tmp:#3*\layerwd+0.5*\layerwd)
        {#6}; %% Options text, rotated, in the middle of the arc
    }%
    \ifnum\theoutermost<#3\setcounter{outermost}{#3}\fi
}

%% |=====8><-----| %%

\begin{document}

\begin{onion}*{0.25in}
    \annulus{0}{0}{90}[1]
    \annulus{0}{90}{180}[2]
    \annulus{0}{180}{270}[3]
    \annulus{0}{270}{360}[4]
    \annulus[yellow]{1}{0}{120}[Y]
    \annulus[red!20]{4}{0}{90}
    \annulus[blue!30]{3}{60}{180}
    \annulus[cyan!20]{2}{45}{130}
    \annulus[purple!20]{2}{165}{325}[more\\stuff]
\end{onion}

\end{document}

gráfico anular

Atualizar

Parecia estranho criar um gráfico anular e não aproveitar as vantagens do TikA capacidade de Z de colocar texto em um caminho. A única mudança é que a \annulusmacro pode usar um opcional *para colocar o texto opcional em um caminho circular. Observe que o texto em um caminho não pode ter quebras de linha; \\fará com que o TeX trave - eu me protegi contra essa possibilidade até certo ponto.

\documentclass{article}

\usepackage{xcolor}
\usepackage{xparse}
\usepackage{tikz}


\usetikzlibrary{calc,positioning}
\usetikzlibrary{decorations, decorations.text}

%% |=====8><-----| %%

\newlength{\layerwd}
\newcounter{outermost}

%% |=====8><-----| %%

\NewDocumentEnvironment{onion}{sm}{%*= draw axes; #1: thickness of each annulus
    \begin{tikzpicture}
        \setlength{\layerwd}{#2}%
        \setcounter{outermost}{0}
        \IfBooleanT{#1}{%
            \draw[<->] (-4,0) -- (4,0);
            \draw[<->] (0,4) -- (0,-4);
        }
}{%
    \foreach \A in {0,...,\theoutermost}{\draw[thick] (0,0) circle (\A*\layerwd+\layerwd);}
    \end{tikzpicture}
}

% *=text on a circular path; [optional fill color]; #3 layer;
% #4 start angle; #5 stop angle; #6 [optional text]
%% angles are counterclockwise in degrees
\NewDocumentCommand{\annulus}{sO{lightgray}mmmo}{%
    \filldraw[thick,fill=#2] (#4:#3*\layerwd) %% start here
        arc [radius=#3*\layerwd, start angle=#4, delta angle=#5-#4] %% inner arc
        -- (#5:#3*\layerwd+\layerwd) %% move out
        arc [radius=#3*\layerwd+\layerwd, start angle=#5, delta angle=#4-#5] %% outer arc
        -- cycle; %% Back to the beginnning
    \pgfmathsetmacro{\tmp}{(#5-#4)/2 +#4} %% Locate the middle of the arc
    \IfNoValueF{#6}{%
        \IfBooleanTF{#1}
        {%
            \begingroup
                \def\\{\space} %% A safety precaution, \\ = space on decorated text
                \path[rotate=\tmp-180,postaction={
                    decorate,
                    decoration={
                        text along path,
                        raise=-3pt,
                        text align={align=center},
                        reverse path=true,
                        text=#6
                    }
                }] (0,0) circle (#3*\layerwd+0.5*\layerwd);
            \endgroup
        }%% 
        {%
            \node[inner sep=0pt, %%% If there is text, print it
            text width=#3*\layerwd*3+\layerwd,
            align=center,
            rotate=\tmp-90,
            font=\footnotesize] at (\tmp:#3*\layerwd+0.5*\layerwd)
            {#6};
        }%
    }%
    \ifnum\theoutermost<#3\setcounter{outermost}{#3}\fi
}

%% |=====8><-----| %%

\begin{document}

\begin{onion}*{0.25in}
    \annulus{0}{0}{90}[1]
    \annulus{0}{90}{180}[2]
    \annulus{0}{180}{270}[3]
    \annulus{0}{270}{360}[4]
    \annulus*[yellow]{1}{0}{120}[Y is yellow]
    \annulus*[red!20]{4}{0}{90}[This is a bunch of bla bla]
    \annulus*[blue!30]{3}{60}{180}[This is some longer text]
    \annulus[cyan!20]{2}{45}{130}
    \annulus[purple!20]{2}{165}{325}[more\\stuff]
\end{onion}

\end{document}

gráfico anular com texto no caminho

Atualização 2

Fizemos uma pequena alteração que garante que o texto na metade inferior do gráfico fique com o lado direito para cima.

\documentclass{article}

\usepackage{xcolor}
\usepackage{xparse}
\usepackage{tikz}


\usetikzlibrary{calc,positioning}
\usetikzlibrary{decorations, decorations.text}

%% |=====8><-----| %%

\newlength{\layerwd}
\newcounter{outermost}

%% |=====8><-----| %%

\NewDocumentEnvironment{onion}{sm}{%*= draw axes; #1: thickness of each annulus
    \begin{tikzpicture}
        \setlength{\layerwd}{#2}%
        \setcounter{outermost}{0}
        \IfBooleanT{#1}{%
            \draw[<->] (-4,0) -- (4,0);
            \draw[<->] (0,4) -- (0,-4);
        }%
}{%
    \foreach \A in {0,...,\theoutermost}{\draw[thick] (0,0) circle (\A*\layerwd+\layerwd);}
    \end{tikzpicture}
}

% *=text on a circular path; [optional fill color]; #3 layer;
% #4 start angle; #5 stop angle; #6 [optional text]
%% angles are counterclockwise in degrees
\NewDocumentCommand{\annulus}{sO{lightgray}mmmo}{%
    \filldraw[thick,fill=#2] (#4:#3*\layerwd) %% start here
        arc [radius=#3*\layerwd, start angle=#4, delta angle=#5-#4] %% inner arc
        -- (#5:#3*\layerwd+\layerwd) %% move out
        arc [radius=#3*\layerwd+\layerwd, start angle=#5, delta angle=#4-#5] %% outer arc
        -- cycle; %% Back to the beginnning
    \pgfmathsetmacro{\tmp}{(#5-#4)/2 +#4} %% Locate the middle of the arc
    \IfNoValueF{#6}{%
        \IfBooleanTF{#1}
        {%
            \begingroup
                %% text is always rightside-up:
                \pgfmathsetmacro{\rpTF}{ifthenelse(\tmp>180,"false","true")}
                \def\\{\space} %% A safety precaution, \\ = space on decorated text
                \path[rotate=\tmp-180,postaction={
                    decorate,
                    decoration={
                        text along path,
                        raise=-3pt,
                        text align={align=center},
                        reverse path=\rpTF,
                        text=#6
                    }
                }] (0,0) circle (#3*\layerwd+0.5*\layerwd);
            \endgroup
        }%% 
        {%
            \pgfmathsetmacro{\rpTF}{ifthenelse(\tmp>180,\tmp+90,\tmp-90)}
            \node[inner sep=0pt, %%% If there is text, print it
            text width=#3*\layerwd*3+\layerwd,
            align=center,
            rotate=\rpTF,
            font=\footnotesize] at (\tmp:#3*\layerwd+0.5*\layerwd)
            {#6};
        }%
    }%
    \ifnum\theoutermost<#3\setcounter{outermost}{#3}\fi
}

%% |=====8><-----| %%

\begin{document}

\begin{onion}*{0.3in}
    \annulus{0}{0}{90}[1]
    \annulus{0}{90}{180}[2]
    \annulus{0}{180}{270}[3]
    \annulus{0}{270}{360}[4]
    \annulus*[yellow]{1}{0}{120}[Y is yellow]
    \annulus*[red!20]{4}{0}{135}[This is a bunch of bla bla]
    \annulus*[blue!30]{3}{60}{180}[This is some longer text]
    \annulus[cyan!20]{2}{45}{130}
    \annulus[white]{3}{225}{315}[Line 1\\Line 2]
    \annulus*[purple!20]{2}{165}{325}[more\\stuff]
\end{onion}

\end{document}

gráfico anular revisado

informação relacionada